PDA

View Full Version : Having trouble with PHP


gatormn
01-28-2010, 10:48 PM
I am a college student and have to send my information form to my .php page but keep getting error code and can not figure this php out.
First of all it is a simple form
With First name,Last name,Email address
now I'm suppose to send the information entered to my .php page
I can not get it to show up on that page
I wonder if anyone could reply with the php code I'm suppose to have to view it in the php page?
I also have 3 hidden fields that the teacher wants us to show up on the php page.
I am stuck and there is nothing out there that I found that will help me figure out this php for dreamweaver cs4
I wait impatiently for a help reply
Thankyou

edbr
01-29-2010, 12:53 AM
you are sending from a for?
if so set the method to POST, you can collect the values then as $_POST values ie
echo $_POST['first_name'] post value matching the form fields you use

check out the PHP tutorials on this forum, they could make you a star in your class

gatormn
01-29-2010, 01:52 AM
HERE is the form code
It is supose to send the information along with the hidden information to the next php page
<form id="form1" name="form1" method="get" action="page3.php">
<p>
<label>
<input name="first" type="text" id="first" />
First name</label>
</p>
<p>
<label>
<input type="text" name="last" id="last" />
Last name</label>
</p>
<p>
<label>
<input type="text" name="email" id="email" />
Email address</label>
<input name="warranty" type="hidden" id="warranty" value=" <?php
echo $_GET['warranty'];
?>" />
<input name="pen" type="hidden" id="pen" value=" <?php echo $_GET['pen']; ?>" />
<input name="book" type="hidden" id="book" value="<?php
echo $_GET['book'];
?>" />
</p>
<p>
<label>
<input type="submit" name="enter" id="enter" value="Submit" />
</label>
</p>
</form>
<h1>&nbsp;</h1>
<h2>Accessories chosen</h2>
<p>&nbsp;</p>

<?php
echo $_GET['warranty'];
?>
<?php
echo $_GET['pen'];
?>
<?php
echo $_GET['book'];
?>
Hope this helps more for you to help me out

gatormn
01-29-2010, 01:56 AM
Now on page3.php I do not know what to put in the code to make it show up on the page.
This is the last step of the problem and most of the students could not figure it out as I.
I think it is a echo but not sure where to put it or how to put it in
Is it suppose to be $_POST not $_GET also ?
Thanks for the quick reply
I'm so frustrated

edbr
01-29-2010, 02:18 AM
yes you can echo the Get variables on page3.php, personally i would use post though with forms
echo $_POST['email']; for example
same with
warranty, last, first etc

i point though dont use php code blocks like you have here
<?php
echo $_GET['warranty'];
?>
<?php
echo $_GET['pen'];
?>
<?php
echo $_GET['book'];
?>

better

<?php
echo $_GET['warranty'];
echo $_GET['pen'];
echo $_GET['book'];
?>

gatormn
01-29-2010, 02:36 AM
Great thanks
Then how do I put it in code to show up on the page3.php?
Like first name, last name and email on the form2 to show up on page 3.php
Do I use a echo for that also? with $_POST?
Thank you , you are a great help and I just wish the instructor would of given us examples that were more like the problem.
He also said he wanted the email to be a link but not sure how that is done at all through php. He never showed us that at all.
Thank again

edbr
01-29-2010, 02:46 AM
yes use echo
not sure what you mean by link in email though.

gatormn
01-29-2010, 03:08 AM
What he said is he wanted the email to show up on page3.php as a link.
Not sure why but I am also not sure if I can do that
Thank you
If I need further help on the next php which is if / else thing with php
may I ask for your help again?
You seem to understand this very good

edbr
01-29-2010, 05:31 AM
sounds like a sparse course. check the tutorials here they will help im sure