Setting up a form in PHP

Reply

Join Date: Oct 2003
Posts: 1
Reputation: deef is an unknown quantity at this point 
Solved Threads: 0
deef deef is offline Offline
Newbie Poster

Setting up a form in PHP

 
0
  #1
Oct 27th, 2003
I am a new student to php and I am working on my first project. I have created an html form, a php output form and a php confirm form. I am having trouble linking them together, when I fill in the information on my form it does not show up in the output form or confirm form.. Any tips or suggestions on what I should do or check?

Thanks,

Joe
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 95
Reputation: jayant will become famous soon enough jayant will become famous soon enough 
Solved Threads: 1
jayant's Avatar
jayant jayant is offline Offline
Junior Poster in Training

Re: PHP help!

 
0
  #2
Nov 10th, 2003
Originally Posted by deef
I am a new student to php and I am working on my first project. I have created an html form, a php output form and a php confirm form. I am having trouble linking them together, when I fill in the information on my form it does not show up in the output form or confirm form.. Any tips or suggestions on what I should do or check?

Thanks,

Joe
Give some code dear, so we can tell where the problem exactly lies instead of firing the dart in the dark

<--- runs looking for those night vision goggles
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 82
Reputation: himerus is an unknown quantity at this point 
Solved Threads: 0
himerus's Avatar
himerus himerus is offline Offline
Junior Poster in Training

Re: PHP help!

 
0
  #3
Nov 15th, 2003
Your basic HTML form is going to have the following:

my example is a quick & dirty login script

Page1.html
  1. <form method=POST action=login.php>
  2. <input type=text name=user_id>
  3. <input type=password name=user_pass>
  4. <input type=submit value=Login>
  5. </form>

Your next page (login.php) will need have the following attributes.
You have 2 variables submitted from the form on the previous page. The variables are $user_id & $user_pass.

Your PHP script now needs to do something with these variables. You can compare the username and password to something stored in your PHP file. (not very secure), or later once you are working with a MySQL database, you can locate the corresponding user's information, and either accept the users login, and redirect them to a members page, or deny the login, and print an error.

In short, your HTML form is going to send variables to the PHP script. When you declare a "name=" on an input field, that variable is sent to the next page with that variable name. Then you have to do something with it. Print it out, manipulate the database with it, etc.

Let me do a little more simple example so you can see just what I mean.

This example will just print out some of the information that a user submits, and nothing else.

  1. <form method=POST action=page.php>
  2. Enter your first name: <input type=text name=first_name><br />
  3. Enter your last name: <input type=text name=last_name><br />
  4. Enter your email address: <input type=text name=email_address><br />
  5. <input type=submit value=Login>
  6. </form>

Now, my next page is going to use the information they submitted, and print it back on the screen.

confirm.php
[php]
// Since we aren't doing anything fancy, the only PHP function
// I'm using here is echo
echo "
Hello, $first_name $last_name,
Thanks for signing up for our newsletter.
I show that your email address is $email_address.
We will be sending your the first copy soon!!! Thanks!
";
[/php]

Note:

Your variables that you've submitted from the HTML form appear simply as $first_name, $last_name, and $email_address. This method of retrieving the variables is not secure.

Someone could type in yourwebsite.com/confirm.php?first_name=Joe&last_name=Flipper&email=

well you get the idea. This can cause problems if you are sending hidden variables to the next page like a user_id, etc.

To avoid this, and the newly adopted way to call varaibles is via an array created by the PHP server automatically.

The same variables above can be obtained by using
$_POST[first_name], $_POST[last_name], and $_POST[email_address].

this guarantees that the values for these items was only submitted to the script using the POST method. If you are taking classes, or reading up to date info, they should ONLY recommend using this option. I learned on the standard variable and have had to switch over to adopt the newer, safer way of retrieving these variables.

Hope this helps a bit, or might point you in the right direction.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 5
Reputation: adilz.cool is an unknown quantity at this point 
Solved Threads: 0
adilz.cool adilz.cool is offline Offline
Newbie Poster

Re: Setting up a form in PHP

 
0
  #4
Jan 9th, 2008
Originally Posted by deef View Post
I am a new student to php and I am working on my first project. I have created an html form, a php output form and a php confirm form. I am having trouble linking them together, when I fill in the information on my form it does not show up in the output form or confirm form.. Any tips or suggestions on what I should do or check?

Thanks,

Joe
I am also having the same problem PHP is not working in my system is there any one who can solve my problem .
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

Re: Setting up a form in PHP

 
0
  #5
Jan 9th, 2008
go to w3schools.com , this will help you
Thanks
VSSP
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC