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 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 ;)

Your basic HTML form is going to have the following:

my example is a quick & dirty login script

Page1.html

<form method=POST action=login.php>
<input type=text name=user_id>
<input type=password name=user_pass>
<input type=submit value=Login>
</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.

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

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

confirm.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!
";

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. :)

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 .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.