Jump to content

Archived

This topic is now archived and is closed to further replies.

jspencer

Help me, i'm drowning!

Recommended Posts

Hello,

Can't find a 'noob' forum so forgive me if this question is too dumb for words.

I just started learning php last week and at my current stage, learn somthing new with every little paragraph i read.

I am using a mac with apache and MySQL installed and i have an account with 1&1. (i'm not trying to give my life story, just painting a picture of my incompitence.)

I am a big believer in being throw in the deep and learning quickely.

So anyway, I have gone through phpfreak's tutorial about setting up user accounts. It's a great tutorial and it taught me loads of stuff but i can't get passed the information collection form part on page 3. It kind of assumes that you know how to set up the collection forms.
He tells you what it does but does not give any code.

Here is the page i mean: http://www.phpfreaks.com/tutorials/40/2.php

Please help.

Thanks,
J

Share this post


Link to post
Share on other sites
go and have a look at this... [url=http://www.w3schools.com/html/html_forms.asp]http://www.w3schools.com/html/html_forms.asp[/url]

Share this post


Link to post
Share on other sites
thanks for thr link but i am familliar with the html part.

What i don't understand is why the saved html file which is being called by a php command in the next page of the tutorial shows the form but also shows:
****
"You did not submit the following required information!
First Name is a required field. Please enter it below.
Last Name is a required field. Please enter it below.
Email Address is a required field. Please enter it below.
Desired Username is a required field. Please enter it below."
****
...even though I submitted information.

This leads me to belive that there should be some additional code with the forms in the html file. Am i wrong?

Share this post


Link to post
Share on other sites
make sure you names ur fields exactly as he did.......caps too

as follows

first_name
last_name
email_address
username
info

Share this post


Link to post
Share on other sites
If you read that part on the form example page he explains that he's not doing any form field validation in the form html itself. Instead he's doing the validation in the register.php file that is called when the form is submitted. If there are errors or empty required fields then it will display one or more of those error messages you posted.

What he said:
[quote]This form will post to a script called register.php and will do a few things that are essential. We'll put some basic error checking with PHP. I am not including any special Error checking functions on this form because everyone likes to do error checking their own way. I'll basically be checking that the user entered the required fields of this form and if they didn't, we'll put an error message on the page that they post this form to.[/quote]

The code doing the verification:
[code]/* Do some error checking on the form posted fields */

if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
    echo 'You did not submit the following required information! <br />';
    if(!$first_name){
        echo "First Name is a required field. Please enter it below.<br />";
    }
    if(!$last_name){
        echo "Last Name is a required field. Please enter it below.<br />";
    }
    if(!$email_address){
        echo "Email Address is a required field. Please enter it below.";
    }
    if(!$username){
        echo "Desired Username is a required field. Please enter it below.<br />";
    }
    include 'join_form.html'; // Show the form again!
    /* End the error checking and if everything is ok, we'll move on to
    creating the user account */
    exit(); // if the error checking has failed, we'll exit the script!
} [/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.