Caleb: what do you mena the $link in the mysql_select_db? I couldn't find that variable.

Caleb: what do you mena the $link in the mysql_select_db? I couldn't find that variable.
I meant $mysql_connection, my bad.
mysql_pconnect is a perfectly legit function. I agree in the context of this script mysql_connect would be a better preference as there is no reason to have a persistent connection to MySQL. mysql_pconnect should only be used in certain circumstances and therefore is not required for most basic web scripts.Originally Posted by Hypertext
You mispelt mysql_connect
Yes, they may be faster, however for a simple small web application this doesn't need to be taken into account. It will make no difference at all. Saying they are faster really only applies for much larger sites such as FaceBook.Originally Posted by HyperText
single quotes are faster than doubles
Same thing:Originally Posted by HyperText
$logged['in'] should be set as true or false, not 1 or 0.
Would echo false.PHP Code:$i=0;
if($i) echo 'true'; else echo 'false';
Would echo true.PHP Code:$i=1;
if($i) echo 'true'; else echo 'false';
You should. It is good practice especially later on when you develop further and wish to connect to several databases at the same time.Originally Posted by HyperText
I personally wouldn't use a mysql connection resource in your database selector
This forum is partly to help other users, therefore if a user posts asking for help you shouldn't turn them away. If the user's PHP level isn't as good as yours, (No offence aimed at you LoserWill) then you should be offering advice. Life is all about learning, not saying "go away".Originally Posted by HyperText
please check your code in a debugger or an ide, coming on here asking about mysql_pconnect, it's to be honest wasting everybodys time when you could see that individual mistake in quarter of a second on an ide or a debugger.
Not true all the time. There are ways of creating IP comparison scripts to help track users on dynamic IPs.Originally Posted by HyperText
ips are dynamic a lot of the time so don't use them
No it isn't, they are the same thing.Originally Posted by HyperText
++$error;
is faster than
$error++
Saying that may be another form of "echo" however you need the short_open_tag option enabled in the PHP Configuration.Originally Posted by HyperText
Use echo equals like <?= $var ?>
I won't comment..Originally Posted by HyperText
HOW THE HECK ARE YOU DOING ALL THIS WITHOUT A SINGLE ERROR TO PRODUCE FOR US?
It is good practice to assign querys to a variable.Originally Posted by HyperText
oh and get rid of $insert = ...why is that there in the first place!!??!
It may be faster in large scale websites however in this instance it will make no difference at all.Originally Posted by HyperText
Seriously Caleb, have you even heard about something called benchmarks, the stuff I said is faster is faster because it is. And your thing about <?= ?> is just plain funny. Your the noob!, noob.
No, that's not it Caleb. (thanks btw.)
I've tried a lot of things and nothing is working. Anybody have any ideas?
Change the query to
PHP Code:$insert = mysql_query ( "INSERT INTO `users` (username, password, email, ip, joindate, jointime) VALUES('$username', '$password', '$email', '$ip', '$date', '$time')" ) or die ( mysql_error () );
PHP Code:<?php
if($logged['in'] == 1){
header("Location: index.php");
}
if(row_exists('users','ip',$ip)){ ?>
Your IP ($ip) has already been registered with.
<?php }
else{
if($_GET["action"] == "register"){
$username = clean($_POST['username']);
$email = clean($_POST['email']);
$password = clean($_POST['password']);
$cpassword = clean($_POST['cpassword']);
$errors = 0;
$error_message = '';
if(empty($username) || empty($email) || empty($password) || empty($cpassword)){
$errors++;
$error_message = 'All fields must be filled in.';
}
if(row_exists('users','username',$username)){
$errors++;
$error_message = 'That username is already taken.';
}
if(row_exists('users','email',$email) || !is_valid_email($email)){
$errors++;
$error_message = 'That email is alreayd in use or is incorrect.';
}
$password = enc($password);
$cpassword = enc($cpassword);
if($password != $cpassword){
$errors++;
$error_message = 'The two passwords you entered do not match.';
}
if($errors = 0){
$insert = mysql_query("INSERT INTO `users` (`username`,`password`,`email`,`ip`,`joindate`,`jointime`) VALUES ('".$username."','".$password."','".$email."','".$ip."','".$date."','".$time."')");
$subject = "Welcome to willSystem";
$body = "Thanks for joining (test message from willSystem demo.)";
send_mail($email,$subject,$body);
?>
Thanks for joining, you may now <a href="login.php">login</a>.
<?php
exit();
} else{
echo $error_message;
}
}
?>
<form method="post" action="?action=register">
Username<br />
<input type="text" name="username" value="<?=$username?>" maxlength="12"><br /><br />
Email<br />
<input type="text" name="email" value="<?=$email?>"><br /><br />
Password<br />
<input type="password" name="password"> Confirm <input type="password" name="cpassword"><br /><br />
<input type="submit" name="register" value="Register"><br /><br />
All fields are required.
</form>
<?php
}
?>
I'll try it when I get back on my main pc. Thanks again for your help.
I've tried adding an action to the form (like yours) and it didn't do anything. I've looked it through many times and fail to see what's wrong with it.
Want to hide these adverts? Register an account for free!