Can I Check if Usernames are already being used in the database?
I would like that one someone submits the form it will tell them if the username they had specified is already in the database.
Is this possible? - i have been trying with different php script but because the form generater writes its script in a non obvious and straight forward fashion im a little lost.
it works very well when it tells me they havnt entered a name or email in the fields - but can it please tell me that the username they have put in is taken within my database?
PLEASE HELP?
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Name');
pt_register('POST','Surname');
pt_register('POST','Username');
pt_register('POST','Password');
pt_register('POST','Email');
Please note that emails sent from Verdegía are scanned by Anti-Span Software. Please allow 30 Minutes to recieve your Registration Conformation.
<!-- Do not change anything below this line -->
<?php
}
?>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is possible but not part of the standard phpFormgenerator. This will require custom modifications to the form or processor.php file. I can see that you used the SQL database option so you would be required to do a SQL query on your db in order to check names in the current db against the name you are attempting to enter.
Not terribly difficult but there is custom work required to omplement this on your form.
If you have a copy of the old phpFormgenerator 2.09c, there is a query function that you can use as an example. This is part of the admin section of the generated form. It has both file and SQL db query capability but not any name checking. That part would still need to be custom.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can I Check if Usernames are already being used in the database?
I would like that one someone submits the form it will tell them if the username they had specified is already in the database.
Is this possible? - i have been trying with different php script but because the form generater writes its script in a non obvious and straight forward fashion im a little lost.
it works very well when it tells me they havnt entered a name or email in the fields - but can it please tell me that the username they have put in is taken within my database?
PLEASE HELP?
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Name');
pt_register('POST','Surname');
pt_register('POST','Username');
pt_register('POST','Password');
pt_register('POST','Email');
//Password Encrypton
$Password=md5($Password);
echo $encrypt_password;
//username Check
$query = "SELECT username FROM members1 WHERE username='$username'";
$result=mysql_query($query);
$user_exists=mysql_result($result,1,"username");
//Required Fields
if($Name=="" || $Surname=="" || $Username=="" || $Password=="" || $Email=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$Name."
Surname: ".$Surname."
Username: ".$Username."
Password: ".$Password."
Email: ".$Email."
";
$message = stripslashes($message);
//Send Mail
mail("info@verdegia.com","Registration at Verdegía",$message,"From: Verdegía");
$link = mysql_connect("sql313.byethost17.com","b17_3328800","268953");
mysql_select_db("b17_3328800_1111",$link);
$query="insert into members1 (Name,Surname,Username,Password,Email) values ('".$Name."','".$Surname."','".$Username."','".$Password."','".$Email."')";
mysql_query($query);
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $Name."|".$Surname."|".$Username."|".$Password."|".$Email."
";
fwrite($make,$to_put);
?>
<!-- This is the content of the Thank you page, be careful while changing it -->
<h2>Thank you, <?php echo $Name; ?> you have sucessfully registered at Verdegía!</h2>
<table width=50%>
<tr><td>Name: </td><td> <?php echo $Name; ?> </td></tr>
<tr><td>Surname: </td><td> <?php echo $Surname; ?> </td></tr>
<tr><td>Username: </td><td> <?php echo $Username; ?> </td></tr>
<tr><td>Password: </td><td> <?php echo $Password; ?> </td></tr>
<tr><td>Email: </td><td> <?php echo $Email; ?> </td></tr>
</table>
Please note that emails sent from Verdegía are scanned by Anti-Span Software. Please allow 30 Minutes to recieve your Registration Conformation.
<!-- Do not change anything below this line -->
<?php
}
?>
It is possible but not part of the standard phpFormgenerator. This will require custom modifications to the form or processor.php file. I can see that you used the SQL database option so you would be required to do a SQL query on your db in order to check names in the current db against the name you are attempting to enter.
Not terribly difficult but there is custom work required to omplement this on your form.
If you have a copy of the old phpFormgenerator 2.09c, there is a query function that you can use as an example. This is part of the admin section of the generated form. It has both file and SQL db query capability but not any name checking. That part would still need to be custom.