eXceem

Go Back   eXceem > Off Topic > Technical Help

Claim your amazing £1,000 slots booster bonus now!


Quick PHP Help?

This is a discussion on Quick PHP Help? within the Technical Help forums, part of the Off Topic category; So basically I have a single field form, and I want whatever is inputted into the field to be added ...

Reply
 
Thread Tools
Old 31-05-10, 09:25 AM   #1
Mini Mac
 
delude's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 4,655
delude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to behold

Quick PHP Help?


So basically I have a single field form, and I want whatever is inputted into the field to be added on to the end of a link, example:

User input='100'

URL = 'http://www.website.com/999&extension=100


Currently I have this in my index.php file:

Code:
form action="submit.php" method="post">
<input name="FieldName" type="text"  />
</div>
<input type="image" src="image/source.jpg" width="x" height="x" />
</form>
And in 'submit.php' I have this:

Code:
<?php
// Change to the URL you want to redirect to
$URL="http://www.website.com/999&extension= $_POST["FieldName"];

header ("Location: $URL");

?>
Obviously this doesn't work as I wouldn't be asking for help, and I also have absolutely no idea about PHP, this is my first go at trying to write something myself.

Maybe it would be better to get rid of submit.php completely? I can take out the '$_POST["FieldName"]' part and just put text or a number and it works fine, but I want it to use the value that the user has typed into the form field.

Any help will be much appreciated!
Thanks
 
Reply With Quote
Old 31-05-10, 10:02 AM   #2
Mini Mac
 
delude's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 4,655
delude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to behold
Sorry, could this please be moved to technical help?
 
Reply With Quote
Old 31-05-10, 10:49 AM   #3
Mini Mac
 
chigley's Avatar
 
Join Date: Sep 2006
Location: Bolton/London (home/uni.)
Posts: 8,424
chigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond reputechigley has a reputation beyond repute
Send a message via MSN to chigley
There are two main issues that I can see with your code.

Issue one is that there is no opening < on the form tag in your HTML. To be honest I'm guessing that you have included this, and it just got cut out in the copy/paste, but I thought I'd mention it just to make sure.

The second problem is that you have no closing " quote at the end of your $URL definition. The corrected code is:

Code:
<?php
// Change to the URL you want to redirect to
$URL="http://www.website.com/999&extension={$_POST["FieldName"]}";

header ("Location: $URL");

?>
Note the {} around the variable within the double quotes. This is not always required, but it is a way of telling PHP that the contents of the curly brackets is a variable. If it was a normal variable name, eg. $userid, you wouldn't have to include it (although it's good practice to anyway if you're using double quotes to enclose your string.) However, since your variable contains double quotes, PHP would error if you omitted the curly brackets, as a result of the additional ""s.

Hope that makes sense?
 
Reply With Quote
Old 31-05-10, 11:02 AM   #4
Mini Mac
 
delude's Avatar
 
Join Date: Mar 2007
Location: UK
Posts: 4,655
delude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to beholddelude is a splendid one to behold
Got to spread the love before giving you rep, thanks so much it works perfectly!!
 
Reply With Quote
Old 31-05-10, 11:06 AM   #5
iPod 20gb
 
NeonLord's Avatar
 
Join Date: Feb 2008
Location: Birmingham
Posts: 892
NeonLord has a spectacular aura about
I gave rep for you as it was a very helpful post
 
Reply With Quote
Old 31-05-10, 11:36 AM   #6
iPod Nano 4GB
 
Origamiguy's Avatar
 
Join Date: Jul 2009
Location: My underground lair
Posts: 305
Origamiguy will become famous soon enough
alternatively, appending using . would work:

Code:
<?php
// Change to the URL you want to redirect to
$URL="http://www.website.com/999&extension=" . $_POST["FieldName"];

header ("Location: $URL");

?>
 
Reply With Quote
Reply

Thread Tools

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 On
Refbacks are Off





All times are GMT. The time now is 08:53 PM.
All trademarks and copyrights held by respective owners. Forum posts are owned by the poster.

Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO
no new posts