Computers |
|
| | #1 (permalink) |
| Ultra Techie Join Date: Jul 2006
Posts: 890
| what is wrong with this part of the script...... if($_POST[’submit’]){ } _POST[’username’] = trim($_POST[’username’]); if($_POST[’username’] && strlen($_POST[’username’]) >= 3){ $query = mysql_query(”SELECT `id` FROM `users` WHERE `username`=’”.$_POST[’username’].”‘ LIMIT 1″); if(mysql_num_rows($query)){ $error[’userexists’] = ‘Username exists’; } } else { $error[’usernameinput’] = ‘Please enter a username of 3+ characters’; } i do have the <?php and <? in but it wont save something about encodings arent ryt and utf-8, it only does this when i add this in. |
| | |
| | #2 (permalink) |
| Master Techie | Try this: PHP Code: Another thing I saw was you had _POST['username'] when it should have been $_POST['username']. Then a few syntax errors in the query, etc. I recommend getting a good script editing program so that you can see errors and whatnot. I use Editplus 2, works quite well and it's free. |
| | |
| | #3 (permalink) |
| Ultra Techie Join Date: Jul 2006
Posts: 890
| i have a problem with this whihc i want to add after and it still anit right the other test. if($_POST[’submit’]){ } _POST[’username’] = trim($_POST[’username’]); if($_POST[’username’] && strlen($_POST[’username’]) >= 3){ $query = mysql_query(”SELECT `id` FROM `users` WHERE `username`=’”.$_POST[’username’].”‘ LIMIT 1″); if(mysql_num_rows($query)){ $error[’userexists’] = ‘Username exists’; } } else { $error[’usernameinput’] = ‘Please enter a username of 3+ characters’; } _POST[’email’] = trim($_POST[’email’]); if($_POST[’email’]){ if(!eregi(”^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$”, $_POST[’email’])){ $error[’emailerror’] = ‘Email Incorrect’; } } else { $error[’emailinput’] = ‘Please supply an email address’; } if($_POST[’password1'] && $_POST[’password2']){ if($_POST[’password1'] != $_POST[’password2']){ $error[’passmismatch’] = ‘Passwords don\’t match’; } } else { $error[’passwordinput’] = ‘Please enter your password in both fields’; } if(!$error && $_POST[’submit’]){ $query = mysql_query(”INSERT INTO `users` (username, email, password) VALUES (’”.$_POST[’username’].”‘, ‘”.$_POST[’email’].”‘, ‘”.md5($_POST[’password1']).”‘)”); if($query){ echo $_POST[’username’].’ is now registered’; } else { Last edited by jay_bo; 06-30-2007 at 01:08 PM. |
| | |
| | #4 (permalink) |
| Master Techie | What is the error exactly? No offense, but that script is pretty sloppy and poorly made. I recommend reading some tutorials for PHP and re-writing it, using comments for clarification. That way when you have errors it's easier to read, easier to interpret, and easier to solve the problems. |
| | |
| | #6 (permalink) |
| Ultra Techie Join Date: Jul 2006
Posts: 890
| if($_POST['submit']){ $_POST['username'] = trim($_POST['username']); if($_POST['username'] && strlen($_POST['username']) >= 3){ $query = mysql_query("SELECT 'id' FROM 'users' WHERE 'username'='".$_POST['username']."' LIMIT 1"); if(mysql_num_rows($query)){ $error['userexists'] = 'Username exists'; } } else { $error['usernameinput'] = 'Please enter a username of 3 or more characters'; } $_POST['email'] = trim($_POST['email']); if($_POST['email']){ if(!eregi("^[a-zA-Z0-9]+[a-zA-Z0-9_.-]*@[a-zA-Z0-9]+[a-zA-Z0-9_.-])*\.[a-z]{2,4}$", $_POST['email'])){ $error['emailerror'] = 'Email Incorrect'; } } else { $error['emailinput'] = 'Please supply an email address'; } if($_POST['password1'] && $_POST['password2']){ if($_POST['password1'] != $_POST['password2']){ $error['passmismatch'] = 'Passwords don\’t match'; } } else { $error['passwordinput'] = 'Please enter your password in both fields'; } if(!$error && $_POST['submit']){ $query = mysql_query("INSERT INTO 'users' (username, email, password) VALUES ('".$_POST['username']."', '".$_POST['email']."', '".md5($_POST['password1'])."')"); if($query){ echo $_POST['username'].'is now registered'; } else { the top line seems 2 be the prob |
| | |
| | #8 (permalink) |
| Monster Techie | Instead of if ($_POST['submit']) you could use if($_SERVER['REQUEST_METHOD'] == 'POST') although both should work. What's wrong with the httpd.conf? Also just for reference, it would be handy (for future questions) if you provided the error that PHP spit out too, as it's usually specific to the problem, just not the exact location. ![]()
__________________ |
| | |
| | #9 (permalink) |
| Ultra Techie Join Date: Jul 2006
Posts: 890
| when people register, they get an email sent to them except apache need to be set up right(httpd.conf) but i cant do it lol i ahve tired.the username ad password do work correct and they are in the database but they dont get sent |
| | |
| | #10 (permalink) |
| Monster Techie | Username and password to what? This here, PHPMailer is an excellent overall mail handler, if you're into playing with stuff for a bit. ![]()
__________________ |
| | |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| New Site Project - Flash + PHP + MySQL + CSS | theone_trent | Web Graphics, design, digital images | 2 | 06-30-2007 01:12 PM |
| Need a good captcha generating php script | surut | Windows Operating Systems and Software | 1 | 05-26-2007 09:23 AM |
| PHP captcha script needed | iorgus | Programming Discussions | 2 | 05-20-2007 01:33 PM |
| PHP 2-player game? | thejeremy | Programming Discussions | 4 | 04-09-2007 06:01 PM |
| Remote file access w/ IP + PHP? | thejeremy | Programming Discussions | 2 | 04-04-2007 05:24 PM |