Hai,

In one of my project I need to add some data into my data base and redirect the page to a different page.

In this case I need to check whether the data has uploaded successfully and then redirect. For a rough sample

mysql_query("INSERT INTO")

if(data added ){
redirect to a page
}
else
Show Error page

I know MySQL query. But please help me with right code

Thanks in advance
Rajeesh

Hai,

In one of my project I need to add some data into my data base and redirect the page to a different page.

In this case I need to check whether the data has uploaded successfully and then redirect. For a rough sample

mysql_query("INSERT INTO")

if(data added ){
redirect to a page
}
else
Show Error page

I know MySQL query. But please help me with right code

Thanks in advance
Rajeesh

Hi, A very simple method would be this

$Query = mysql_query("INSERT INTO `table` (name,age) VALUES ('$name','$age')");
	if (!$Query){
		echo "ERROR: " .mysql_error();
	}
		
		else{ echo " Added to Database";}

Hope it helps..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.