Re: [PHP-DB] How do I submit data AND send user to other page?
On Mon, 2002-08-26 at 13:25, Gerd Ulrich wrote: > Hello, I want to build a questionaire where the user is guided through five > pages of questions. How can I program PHP that the user gets to the second > page after pushing the "Submit"-Button? > My solution printed here doesn't work. > Any hints are greatly apreciated! > > S. Maier > > if ($submit) { > // process form > require ('.htmypasswd'); > $verbnr = mysql_connect ($dbhost,$dbuser,$dbpasswd); > $db = mysql_connect($dbhost,$dbuser,$dbpasswd); > mysql_select_db("pretest",$db); > $sql = "INSERT INTO frage3 (a1,a2,a3,be_fe01,be_fe02) VALUES > ('$a1','$a2','$a3','$be_fe01','$be_fe02')"; > $result = mysql_query($sql); > header ("Location: http://www.example.com";); > exit; > } else{ > // display form > ?> easiest way I know to do it is in your form action . as in http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How do I submit data AND send user to other page?
Hi Adam, I think that you have to put the header command before anything else. (that is, putting the header (Location:X) command at the bottom of your block might be the trouble) If putting it somewhere else in your script doesn't work, how about: echo ""; echo ""; echo ""; ...at the top of your if($submit) block, assuming magic quotes are on. This will refresh the page after 1 second to www.example.com, and I think that spitting out that HTML will have no bearing on the executing of the rest of the script (so your query will execute, or try to). If, for some reason, the redirect doesn't happen automatically, or if 1 second isn't fast enough for the user, you could add: echo "Record updated. If this page does not automatically refresh after 1 second, you can proceed by clicking here."; This assumes, of course, that you have immense confidence in your database and query. You might want to check for the query's success before asserting that everything's OK and redirecting. -Colin Odden (OSU Sociology) >On Mon, 26 Aug 2002, Gerd Ulrich wrote: > > > Hello, I want to build a questionaire where the user is guided through five > > pages of questions. How can I program PHP that the user gets to the second > > page after pushing the "Submit"-Button? > > My solution printed here doesn't work. > > Any hints are greatly apreciated! > > > > S. Maier > > > > > if ($submit) { > > // process form > > require ('.htmypasswd'); > > $verbnr = mysql_connect ($dbhost,$dbuser,$dbpasswd); > > $db = mysql_connect($dbhost,$dbuser,$dbpasswd); > > mysql_select_db("pretest",$db); > > $sql = "INSERT INTO frage3 (a1,a2,a3,be_fe01,be_fe02) VALUES > > ('$a1','$a2','$a3','$be_fe01','$be_fe02')"; > > $result = mysql_query($sql); > > header ("Location: http://www.example.com";); > > exit; > > } else{ > > // display form > > ?> > > > > > > > > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How do I submit data AND send user to other page?
use an HTML form. Adam On Mon, 26 Aug 2002, Gerd Ulrich wrote: > Hello, I want to build a questionaire where the user is guided through five > pages of questions. How can I program PHP that the user gets to the second > page after pushing the "Submit"-Button? > My solution printed here doesn't work. > Any hints are greatly apreciated! > > S. Maier > > if ($submit) { > // process form > require ('.htmypasswd'); > $verbnr = mysql_connect ($dbhost,$dbuser,$dbpasswd); > $db = mysql_connect($dbhost,$dbuser,$dbpasswd); > mysql_select_db("pretest",$db); > $sql = "INSERT INTO frage3 (a1,a2,a3,be_fe01,be_fe02) VALUES > ('$a1','$a2','$a3','$be_fe01','$be_fe02')"; > $result = mysql_query($sql); > header ("Location: http://www.example.com";); > exit; > } else{ > // display form > ?> > > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How do I submit data AND send user to other page?
Hello, I want to build a questionaire where the user is guided through five pages of questions. How can I program PHP that the user gets to the second page after pushing the "Submit"-Button? My solution printed here doesn't work. Any hints are greatly apreciated! S. Maier http://www.example.com";); exit; } else{ // display form ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php