Redirect

This is a discussion on Redirect within the MySQL Database forums, part of the Database Forums category; I have been running a form to collect data and send to an email adress with formmail. It was time ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2006
Garry Jones
 
Posts: n/a
Default Redirect

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


Reply With Quote
  #2 (permalink)  
Old 04-11-2006
Bill Karwin
 
Posts: n/a
Default Re: Redirect

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.
Reply With Quote
  #3 (permalink)  
Old 04-11-2006
Good Man
 
Posts: n/a
Default Re: Redirect

"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

Reply With Quote
  #4 (permalink)  
Old 04-12-2006
Garry Jones
 
Posts: n/a
Default Re: Redirect

"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


Reply With Quote
  #5 (permalink)  
Old 04-12-2006
Bill Karwin
 
Posts: n/a
Default Re: Redirect

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.
Reply With Quote
  #6 (permalink)  
Old 04-12-2006
Geoff Muldoon
 
Posts: n/a
Default Re: Redirect

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
Reply With Quote
  #7 (permalink)  
Old 04-12-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Redirect

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
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:50 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0