Hello I am having trouble getting this simple script to work that I wrote, if anyone could tell me what I am doing wrong that would be great
Fatal error: Function name must be a string in /home/volo/public_html/testscript/do_reg.php on line 21
Thanks!!!!
Posted by Jatinder, 07-22-2008, 02:22 PM
Post the code for do_reg.php script.
The code you posted above will run although it will display some notices and warnings.
Posted by whmcsguru, 07-22-2008, 02:26 PM
Firstly, you need to make sure you sanitize your user input. The posted script is going to be insecure as all hell.
Secondly, take a look at the script (do_reg.php), on line 21. Look for an $ where there shouldn't be, because that is usually where this comes from
Posted by ihosty, 07-22-2008, 02:29 PM
php //connection
$host = "localhost";
$dbuser = "username goes here";
$dbpass = "password to database here";
$dbname = "database name here";
$connection = mysql_connect ($host,$dbuser,$dbpass);
$db = mysql_select_db($dbname,$connection);
//grab data from form
$name = $_POST(username);
$pass = $_POST(password);
$pass_conf = $_POST(pass_conf);
$email = $_POST(email);
$ip = $_POST(ip);
//if else (else if)
if ($name == false || $pass == false || $pass_conf == false || $email == false){
echo "please fill in all the required fields.";
}
if($pass != $pass_conf){
echo "Passwords do not match.";
}else {
$connection = mysql_connect ($host,$dbuser,dbpass);
$db = mysql_select_db($dbname,$connection);
$sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip)";
$result = mysql_query($sql);
echo "Thanks By: Matthew Troup";
?>
It then also feeds off a small form, which is the following..
< form name=reg action=do_reg.php method=post>
Username:
Password:
Confirm:
Email:
Posted by Jatinder, 07-22-2008, 02:41 PM
Your "Grab the form data" section is wrong.
It should be:
instead of
And do consider linux-tech's advice and add some input sanitization. At least use mysql_real_escape_string() in your SQL query.
Posted by ihosty, 07-22-2008, 03:22 PM
now i get this...
please fill in all the required fields.
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'volo'@'localhost' (using password: YES) in /home/volo/public_html/testscript/do_reg.php on line 41
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/volo/public_html/testscript/do_reg.php on line 43
Thanks By: Matthew Troup
Posted by Votii, 07-22-2008, 03:36 PM
Replace:
With:
Posted by Votii, 07-22-2008, 03:48 PM
I have also noticed you are missing a
Which should be put on the end of this statement: