It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

News

Log In Sponsors
Partner Sites

Re: Inputting into DB issues



No luck,

Here is the code for the working signup script:

[code:qtqcxiot]
<?
if(isset($todo) and $todo=="post"){

$status = "OK";
$msg="";

// if userid is less than 3 char then status is not ok
if(!isset($userid) or strlen($userid) <3){
$msg=$msg."User id should be =3 or more than 3 char length<BR>";
$status= "NOTOK";}

if(mysql_num_rows(mysql_query("SELECT username FROM member WHERE username = '$userid'"))){
$msg=$msg."User already exists. Please try another Username<BR>";
$status= "NOTOK";}


if ( strlen($password) < 3 ){
$msg=$msg."Password must be more than 3 char length<BR>";
$status= "NOTOK";}

if ( $password <> $password2 ){
$msg=$msg."Passwords do not match, please try again.<BR>";
$status= "NOTOK";}


if ($agree<>"yes") {
$msg=$msg."You must agree to terms and conditions<BR>";
$status= "NOTOK";}

if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
}else{ // if all validations are passed.
$salt = md5($password);
$mdpass = md5($salt.$password);
$query=mysql_query("insert into member(username,password,email,name) values('$userid','$mdpass','$email','$name')");
echo "<font face='Verdana' size='2' color=green>Welcome, You have successfully signed up<br><br><a href=login.php>Click here to login</a><br></font>";
}
}
?>
[/code:qtqcxiot]


And the table with the form:
[code:qtqcxiot]

<span class="sub">Sign-up</span><br />

<form name="form1" method="post" action="signup2.php" onsubmit='return validate(this)'><input type=hidden name=todo value=post>
<table border=0 cellpadding="2px" cellspacing="2px" align="left" width="400px">
<tr><td>Username:</td><td><input name="userid" type="text" size="17" maxlength="20" /></td></tr>

<tr><td>Password:</td><td><input name="password" type="text" size="17" maxlength="20" /></td></tr>

<tr><td>Re-enter Password:</td><td><input name="password2" type="text" size="17" maxlength="20" /></td></tr>

<tr><td>Email:</td><td><input name="email" type="text" size="17" maxlength="50" /></td></tr>

<tr><td>Name:</td><td><input name="name" type="text" size="17" maxlength="20" /></td></tr>

<tr><td>I agree to terms and conditions</td><td><input type=checkbox name=agree value='yes'></td></tr>

<tr><td></td><td><input type="submit" value="Submit" /></td></tr>

</table>
</form>
[/code:qtqcxiot]

Click here to read the whole forum topic