Jump to content

Real problems


mellowmuppet

Recommended Posts

I am trying to do some 'simple' validation: This is the code i am useing

<form action="" method="get">
<p>Please enter your name, </p><input type="text" name="name" />
<?php if (empty($_GET['name'])) 
{ 
echo "You must enter your name<"
} 
?>

//Some code emitted (same as above basically)


<input type="Submit" />
</form> 

 

If you look at the code it should, when nothing is put in the form flag up an error and display the text. it only displays a blank page though which is frustrating. Im fairly new to php and my lecturers code doesnt work either.

I use a Xampp setup and its all up and running and am configuring with notepad ++

 

 

After doing this i need to make sure that its > 3 characters but < 15 how would i implement this into the code on the same page.

 

Should i create a seperate .php page which does tihs part and leave the validation on the html form?

 

Thanks

 

MM

 

(edited by kenrbnsn to add


tags for better readability)

Link to comment
Share on other sites

echo "You must enter your name<"

 

is supposed to be  echo "You must enter your name</body></html>";  i think but i have updated the code for that

 

Im simply trying to create a form that will validate the information in that page before i take them to another page.

 

 

unless the requirements are met it will return an error message on the same page and ask the user to correct

 

so the field must have some data  and this data must be within the range of 3 - 15 characters long

 

Link to comment
Share on other sites

I give up. no errors are being returned so im just going to ignore it.

<?php

 

// Set up error reporting.

error_reporting(E_ALL);

ini_set("display_errors","2");

 

?>

 

 

no errors reported

 

thanks for your help though. ive been pissing around with this for like 3 hours now an im just getting really angry

 

all i have to do is the following.

 

Produce a PHP page that validates data entered in the field. You should at a very minimum validate presence, length and range.

 

It just wont do what its told. funny im stuck on this cause ive done all the other stuff with SQLyog apache and everything. jsut really winds me up hence why i should never be a programmer

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.