Validating form field with table fields in MYSQL through PHP .... how do i do that!

Recommended Answers

All 4 Replies

How do you mean? Validating a form that sends data to a MySQL database?

for that i use (js):

<html>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}function validate_form(thisform)
{
with (thisform)
{
if (validate_required(email,"Email must be filled out!")==false)
  {email.focus();return false;}
/* Copy and paste this part for as many fields as you want to validate*/
if (validate_required(name,"Please fill in you name!")==false)
  {name.focus();return false;}
}
}
</script>
</head><body>
<form action="Insertsubmitpagehere.html"
onsubmit="return validate_form(this)"
method="post">
Name: <input type="text" name="name" size="30"><br />
Email: <input type="text" name="email" size="30"><br />

<input type="submit" value="Submit"> 
</form>
</body></html>

Its not terribly advanced and it only checks that a field isn't empty, but it does the job for me.

NO!

I meant that .... For Example:

A user registers on my site for a Personal Proxy. In the MySQL Database the username Field is the unique field .... The user has no idea that the form is not being submitted b/c they havent provided a username that IS NOT taken. SO what is supposed to happen is that the 'useername' field is checked against the databse table to see if its avaliable .... and displays to the user that its avaliable/unavaliable .... i have searched for this on the Internet and found nothing!

If you dont understand please PM me or contact me through my profile information!

Thanks and Hav ea Blessed Day from MDT International of Tampa, FL

on the submit, do a query on the database before trying to do the insert

display the message and make the user reenter the field

then do the same thing all over again

NO!

I meant that .... For Example:

A user registers on my site for a Personal Proxy. In the MySQL Database the username Field is the unique field .... The user has no idea that the form is not being submitted b/c they havent provided a username that IS NOT taken. SO what is supposed to happen is that the 'useername' field is checked against the databse table to see if its avaliable .... and displays to the user that its avaliable/unavaliable .... i have searched for this on the Internet and found nothing!

If you dont understand please PM me or contact me through my profile information!

Thanks and Hav ea Blessed Day from MDT International of Tampa, FL

Oh sorry I misinterpreted your question...

Have a look at: http://forums.tutorialized.com/php-91/php-mysql-and-php-the-keys-to-a-dynamic-web-page-4822.html

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.