Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Redirection On Form Submit Help Needed
Old 03-26-2010, 06:46 AM Redirection On Form Submit Help Needed
Novice Talker

Posts: 9
Trades: 0
Hi everyone,

I am making a site and i have a fully working register form that post information to a database. But after a submit, I would like to redirect the user to a new page, basically a "Congrats, your a member" page with some info on how to get started. Below is my current form code.

Code:
<form method="post" action="">
<fieldset>
<legend>Account Details</legend>
<p><label for="username" style="font-weight:normal;width:60%;float:left;display:block;">Username:</label> <input type="text" name="username" class="item" value="" /></p>
<p><label for="password" style="font-weight:normal;width:60%;float:left;display:block;">Password:</label> <input type="password" name="password" class="item" value="" /></p>
<p><label for="email" style="font-weight:normal;width:60%;float:left;display:block;">Email Address:</label> <input type="text" name="email" class="item" value="" /></p>
</fieldset>
<fieldset class="other">
<legend>Personal Details</legend>
<p><label for="f_name" style="font-weight:normal;width:60%;float:left;display:block;">First Name:</label> <input type="text" name="f_name" class="item" value="" /></p>
<p><label for="l_name" style="font-weight:normal;width:60%;float:left;display:block;">Last Name:</label> <input type="text" name="l_name" class="item" value="" /></p>
<p><label for="street" style="font-weight:normal;width:60%;float:left;display:block;">House Address:</label> <input type="text" name="street" class="item" value="" /></p>
</fieldset>
<fieldset class="otherqw">
<legend>Shipping Details</legend>
<p><label for="state" style="font-weight:normal;width:60%;float:left;display:block;">State:</label> <select name="state" name="state" class="item"><option value="AL">Alabama</option><option value="AK">Alaska</option><option value="AZ">Arizona</option><option value="AR">Arkansas</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DE">Delaware</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="HI">Hawaii</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="IA">Iowa</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="ME">Maine</option><option value="MD">Maryland</option><option value="MA">Massachusetts</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MS">Mississippi</option><option value="MO">Missouri</option><option value="MT">Montana</option><option value="NE">Nebraska</option><option value="NV">Nevada</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NY">New York</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PA">Pennsylvania</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VT">Vermont</option><option value="VA">Virginia</option><option value="WA">Washington</option><option value="WV">West Virginia</option><option value="WI">Wisconsin</option><option value="WY">Wyoming</option></select>
<p><label for="city" style="font-weight:normal;width:60%;float:left;display:block;">City:</label> <input type="text" name="city" class="item" value="" /></p>
<p><label for="zip" style="font-weight:normal;width:60%;float:left;display:block;">Zip/Postal:</label> <input type="text" name="zip" class="item" value="" /></p>
<p><?php
$ip = $_SERVER['REMOTE_ADDR'];
print "<strong>Logged Your IP:</strong>\n";
print "$ip<br />";
?>
</p>
<p><input type="submit" name="register" class="joinbtn" value=""  /></p>
</fieldset>
</form>
I cant seem to get both things working. For instance, i can redirect to a new page, but the form wont post its data to my database, but if i dont do a redirection, it posts to the database. Please help me with this problem.
astereo90 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-26-2010, 09:50 AM Re: Redirection On Form Submit Help Needed
Experienced Talker

Posts: 31
Trades: 0
Hi astereo90,

I would put in a javascript redirection on the page that takes the data and puts it into the database...

Try putting this in your page-
<script type="text/javascript">
<!--
window.location = "http://www.YOURURLHERE.com"
//-->
</script>

Hope this helps!
-Dillon
Dillon is offline
Reply With Quote
View Public Profile
 
Old 03-27-2010, 12:41 PM Re: Redirection On Form Submit Help Needed
Novice Talker

Posts: 9
Trades: 0
You can also redirect with PHP:

PHP Code:
header("Location:http://site/confirmation.php");
exit(); 
Make sure that this is done before outputting anything. That is, put it before the <html> tag because otherwise it will fail.

See: http://php.net/manual/en/function.header.php
paul.h is offline
Reply With Quote
View Public Profile
 
Old 03-27-2010, 08:47 PM Re: Redirection On Form Submit Help Needed
Novice Talker

Posts: 9
Trades: 0
Never mind, i got it to work after fooling around with my code for a while. Thanks for your replies paul and dillon!

Last edited by astereo90; 03-27-2010 at 09:14 PM.. Reason: thanks for your help, it works now!
astereo90 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Redirection On Form Submit Help Needed
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40267 seconds with 12 queries