...

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



m-hrt
05-13-2009, 05:36 PM
:confused:

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>
</select>*******

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(NAME("DV")+READONLY())+INPUT(TYPE("button")+VALUE("Calender")+ONCLICK("popCal(this.form.DV)"))).FORM().write();
</script></CENTER><br><br><br>


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

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

</form>


PHP CODE


<?php

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

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

mysql_select_db("online_bus_project");


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


}

?>

Fumigator
05-13-2009, 06: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.

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

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

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

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

Fumigator
05-13-2009, 09: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.

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

thanx for the help



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum