Jump to content


Photo

Help me, i'm drowning!


  • Please log in to reply
4 replies to this topic

#1 jspencer

jspencer
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 August 2006 - 06:30 PM

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...orials/40/2.php

Please help.

Thanks,
J

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 August 2006 - 06:32 PM

go and have a look at this... http://www.w3schools.../html_forms.asp
follow me on twitter @PHPsycho

#3 jspencer

jspencer
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 August 2006 - 06:44 PM

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?

#4 legohead6

legohead6
  • Members
  • PipPipPip
  • Advanced Member
  • 434 posts

Posted 08 August 2006 - 08:28 PM

make sure you names ur fields exactly as he did.......caps too

as follows

first_name
last_name
email_address
username
info
"Syntax error" .. WHERE THE **** IS IT?!

#5 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 08 August 2006 - 08:40 PM

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:

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.


The code doing the verification:
/* 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!
}






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users