This is a discussion on Redirect within the MySQL forums, part of the Database Server Software category; --> I have been running a form to collect data and send to an email adress with formmail. It was ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have been running a form to collect data and send to an email adress with formmail. It was time consuming to retreive the data so now I have migrated to a new provider that includes php and mysql. The forms action is therefore now a php script which processes the form and sends to an SQL database. When using formmail the following <input type=hidden name="redirect" value="http://www.mydomain.com/redirect.html"> redirected the user to a page of my choice. I would like to emulate this function with MYSQL. I am aware of the message I can send to a user to say "data sucessfully submitted", but I want to return the user to a specific page on my website. I cant find this syntax for this code anywhere. For what its worth here is my current form action command row. FORM action="process.php" method="post" name="animals" id="animals" > I have tried adding some redirect code to the end of process.php but cant it to work. Garry Jones Sweden |
| |||
| "Garry Jones" <garry.jones@morack.se> wrote in news:e1gvsq$ltq$2@yggdrasil.glocalnet.net: > I cant find this syntax for this code anywhere. > > For what its worth here is my current form action command row. > FORM action="process.php" method="post" name="animals" id="animals" > > > I have tried adding some redirect code to the end of process.php but > cant it to work. FYI this has nothing to do with MySQL and should be posted elsewhere. That being said, the PHP function Header() is what you are looking for. So, on your PHP page that processes the MySQL data, the following code should be entered AFTER all processing and BEFORE any output to the screen: Header("Location: nextpage.php"); See ya |
| |||
| Garry Jones wrote: > <input type=hidden name="redirect" > value="http://www.mydomain.com/redirect.html"> > > redirected the user to a page of my choice. I would like to emulate this > function with MYSQL. I'm not sure how you mean. MySQL doesn't know anything about web forms or HTTP redirects. Do you mean that the URL in that value attribute should be queried from a MySQL table? Regards, Bill K. |
| |||
| "Good Man" <heyho@letsgo.com> skrev i meddelandet news:Xns97A2A23587951sonicyouth@216.196.97.131... > That being said, the PHP function Header() is what you are looking for. > So, on your PHP page that processes the MySQL data, the following code > should be entered AFTER all processing and BEFORE any output to the > screen: > Ok, I know this question is now off topic. However, I have followed your answer and can't get it to work. As this loosely connected to MySql I take the extreme liberty of asking for more clarity. This is the php page that processes the MySQL data. <? $realname=$_POST['realname']; $land=$_POST['land']; mysql_connect("localhost", "myusername", "mypassword") or die(mysql_error()); mysql_select_db("my_database") or die(mysql_error()); mysql_query("INSERT INTO `animals` VALUES ('$realname', '$land')"); Header("Location: http://www.mydomain.com/"); ?> But it does not work, it adds the data in correctly and leaves the user on a totally blank page. Any idea? Garry Jones Sweden |
| |||
| garry.jones@morack.se says... > Ok, I know this question is now off topic. However, I have followed your > answer and can't get it to work. As this loosely connected to MySql I take > the extreme liberty of asking for more clarity. This is the php page that > processes the MySQL data. > > <? > $realname=$_POST['realname']; > $land=$_POST['land']; > mysql_connect("localhost", "myusername", "mypassword") or > die(mysql_error()); > mysql_select_db("my_database") or die(mysql_error()); > mysql_query("INSERT INTO `animals` VALUES ('$realname', '$land')"); > Header("Location: http://www.mydomain.com/"); > ?> > > But it does not work, it adds the data in correctly and leaves the user on a > totally blank page. 1) Subscribe to comp.lang.php 2) Stop using the short tag <? and use full one <?php 3) Turn on full error reporting 4) Check that your script isn't outputting anything (including whitespace) to the browser before the Header call, as it then won't work GM |
| |||
| Garry Jones wrote: > Header("Location: http://www.mydomain.com/"); > ?> > > But it does not work, it adds the data in correctly and leaves the user on a > totally blank page. I'm not a regular PHP user, but it seems to me that PHP variable names are case-sensitive. I assume function names are case-sensitive too. The docs for the header function spell it in lower-case, so your code above could be referencing a non-existant function by the name Header(). See http://www.php.net/manual/en/function.header.php Regards, Bill K. |
| ||||
| Bill Karwin wrote: > Garry Jones wrote: > >> Header("Location: http://www.mydomain.com/"); >> ?> >> >> But it does not work, it adds the data in correctly and leaves the >> user on a totally blank page. > > > I'm not a regular PHP user, but it seems to me that PHP variable names > are case-sensitive. I assume function names are case-sensitive too. > > The docs for the header function spell it in lower-case, so your code > above could be referencing a non-existant function by the name Header(). > > See > http://www.php.net/manual/en/function.header.php > > Regards, > Bill K. No, function names are not case sensitive. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |