Jump to content

validate input from form???


gk20

Recommended Posts

I have a form where I accept an email from the user. I enter their username and email into a table called validate, and then validate the email to see whether it ends in a certain domain. If it does then I submit all the user details into the user table. If not, then $problem=true; etc...
Whether or not the email validation evaluates to true, I delete the entry i just added to the validate table
Heres my code:

$username = $_POST['username'];
$Email = $_POST['Email'];
......
$validatename = $_POST['username'];
$validateemail = $_POST['Email'];
.....

$insertval = "INSERT INTO validate SET
validatename = '$username',
validateemail = '$Email' ";


$emailval = @mysql_query("select validateemail from validate
where validateemail like '%student.example.com'
OR validateemail like '%EXAMPLE.IE'
OR validateemail like '%STAFF.EXAMPLE.COM'");

if (mysql_num_rows($emailval) == 1)
{
$sql = "INSERT INTO user SET
fullname='$fullname',
username='$username',
password='$password',
Email='$Email',
DOB='$DOB',
phonenum='$phonenum' ";

// delete from validate table here and also if $problem = true;

}
else {
echo '<b>Invalid Email</b>';
$problem = true;
}

I also check whether or not the info was inserted into user table corectly etc...
but I get an error saying incorect argument passed to mysql_num_rows ?????? something like that??

Can anyone help?Its wrecking my head?
Link to comment
Share on other sites

you cant use set in an insert statment, you need to write like this:

[code]
INSERT INTO user (
fullname,
username,
password,
Email,
DOB,
phonenum)
values(
'$fullname',
'$username',
'$password',
'$Email',
'$DOB',
'$phonenum')
[/code]
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.