View Full Version : send data to database after that goto other page

05-13-2009, 06:36 PM

i have some data which is send to data base i want to go to other page after sending data how can i do this?????

if im doing in action="example.php" its not working it goes to the page but data not sent.

if im doing it with its self
action="<?php echo $_SERVER['PHP_SELF']; ?>" it sends the data and stays on that page???

what should i do?

send data to data base and goes to other page for further process.

<form name="tstest" action="" method="POST">
** <CENTER>From : <select name="fromcombo">
<option value="khairpur">Khairpur</option>
<option value="sukkur">Sukkur</option>

To : <select name="tocombo">
<option value="karachi">Karachi</option>
<option value="hyderabad">Hyderabad</option>
</select></CENTER><br /><br><br>

<CENTER>Journey Date*:*<script type="text/javascript" language="javascript">

<input type="hidden" name="action" value="add">

<center><input type="submit" value="Submit Info" /></CENTER>




if (isset($_POST['action'])){

mysql_connect("localhost", "root", "autodeskmaya");
header("Location: http://localhost/site/checkstatus.html");


mysql_query("INSERT INTO trip (gender, country, date) VALUES ('$_POST[fromcombo]', '$_POST[tocombo]', '$_POST[DV]')");



05-13-2009, 07:07 PM
If you put your INSERT query in example.php, and then direct to example.php on the form action parameter, then I think you'll have what you want.

05-13-2009, 09:26 PM
can u show me a example how to do this?

05-13-2009, 09:28 PM
i understand now let me try it ill let u know if it works thanx

05-13-2009, 09:32 PM
no its not working any other solutions?

05-13-2009, 09:32 PM
same no data send it direct to example.php but it wont send the data to table.

05-13-2009, 10:56 PM
Echo your $_POST array using print_r() at the top of example.php to see if you're even getting the form data over.

05-13-2009, 11:12 PM
its working with header thanx Fumigator rep added.

thanx for the help