Jump to content

Recommended Posts

still very new... trying to figure all this out... i get an error on line 28 i dont know why... take a look tell me what i did do right thx... if someone has aim or something and wanna help me for quick questions i'd be very gratefull :) ...

 

<?php

 

$host="LOCAL"; // Host name

$username="bludgeonaccount"; // Mysql username

$password="RANDOM"; // Mysql password

$db_name="bludgeonaccount"; // Database name

$tbl_name="members"; // Table name

 

mysql_connect ("$host, $username, $password") or die ("cannot connect");

mysql_select_db ("$db_name")or die("cannot select DB");

 

 

$name=$_POST['username'];

$pass=$_POST['password'];

$pass_conf=$_POST['pass_conf'];

$email=$_POST['email'];

$ip=$_POST['ip'];

 

if($name == false || $pass == false || $email ==false) {

echo "Please fill in all the required fields.";

};

if($pass != $pass_conf){

echo "Passwords do not match.";

} else {

 

mysql_connect ("$host, $username, $password") or die ("cannot connect");

mysql_select_db ("$db_name")or die("cannot select DB");

$sql="INSERT INTO $tbl_name(username, password, email)VALUES('$username','$password','$email')";

$result=mysql_query($sql)or die("MySQL ERROR: ".mysql_error());

 

echo "thank you for your registration to cndalliance.com";

};

 

?>

 

<?php

$host="LOCAL"; // Host name
$username="bludgeonaccount"; // Mysql username
$password="RANDOM"; // Mysql password
$db_name="bludgeonaccount"; // Database name
$tbl_name="members"; // Table name

mysql_connect ("$host, $username, $password") or die ("cannot connect");
mysql_select_db ("$db_name")or die("cannot select DB");


$name=$_POST['username'];
$pass=$_POST['password'];
$pass_conf=$_POST['pass_conf'];
$email=$_POST['email'];
$ip=$_POST['ip'];

if($name == false || $pass == false || $email ==false) {
echo "Please fill in all the required fields.";
}
if($pass != $pass_conf){
echo "Passwords do not match.";
} else {

$sql="INSERT INTO $tbl_name(username, password, email)VALUES('$username','$password','$email')";
$result=mysql_query($sql)or die("MySQL ERROR: ".mysql_error());

echo "thank you for your registration to cndalliance.com";
}

?>

 

1- There should no semicolon after if statement.

2- No need to include twice db code.

Semicolons after if should not produce any errors though. What is the error message?

 

well i would have an answer for you but now all of a sudden i cant connect to my database... i have no idea what i messed up now.. i'll have my code up and error messages shorts...

 

 

 

Post your updated code.

 

Still dont know whats wrong... i keep getting the error below... if any one has a good tutorial i could go look at that will show me how to make a safe login registration form/database WOULD BE GREATLY APPRECIATED

 

Parse error: syntax error, unexpected ')' in D:\Hosting\4688039\html\login2\do_reg.php on line 28

 

<?php

$host="bludgeonaccount.db.4688039.hostedresource.com"; // Host name 
$username="bludgeonaccount"; // Mysql username 
$password="Greater99"; // Mysql password 
$db_name="bludgeonaccount"; // Database name 
$tbl_name="user"; // Table name 

mysql_connect ("$host, $username, $password") or die ("cannot connect");
mysql_select_db ("$db_name")or die("cannot select DB");


$name=$_POST['username'];
$pass=$_POST['password'];
$pass_conf=$_POST['pass_conf'];
$email=$_POST['email'];
$ip=$_POST['ip'];

if($name == false || $pass == false || $email ==false) {
echo "Please fill in all the required fields.";
};
if($pass != $pass_conf){
echo "Passwords do not match.";
} else {

mysql_connect ("$host, $username, $password") or die ("cannot connect");
mysql_select_db ("$db_name")or die("cannot select DB");
$sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip");
$result = mysql_query($sql);
echo "thank you for your registration to cndalliance.com";
}

?>

$sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip");

 

Should be

 

$sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip)";

 

ok i fixed that now it looks as if i screwd up somewere on the database side wtih sql... does it look like i made an error up there... i double checked all of it it say its correct.. but i have no idea what to do now...

ALWAYS post the error message. That way it will make it much easier to spot the problem. Simply saying "what's wrong with my code?" is like asking someone to help you look for your keys in your entire home town when you know they're in your house...

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'bludgeonaccount.db.4688039.hostedresource.com, bludgeonaccount, Greater99' (11004) in D:\Hosting\4688039\html\login2\do_reg.php on line 9
cannot connect

 

thats the error i keep recieving

 

<?php

$host="bludgeonaccount.db.4688039.hostedresource.com"; // Host name 
$username="bludgeonaccount"; // Mysql username 
$password="Greater99"; // Mysql password 
$db_name="bludgeonaccount"; // Database name 
$tbl_name="user"; // Table name 

mysql_connect ("$host, $username, $password") or die ("cannot connect");
mysql_select_db ("$db_name")or die("cannot select DB");


$name=$_POST['username'];
$pass=$_POST['password'];
$pass_conf=$_POST['pass_conf'];
$email=$_POST['email'];
$ip=$_POST['ip'];

if($name == false || $pass == false || $email ==false) {
echo "Please fill in all the required fields.";
};
if($pass != $pass_conf){
echo "Passwords do not match.";
} else {

mysql_connect ("$host, $username, $password") or die ("cannot connect");
mysql_select_db ("$db_name")or die("cannot select DB");
$sql = "INSERT INTO user (username,password,email,ip) VALUES ('$name','$pass','$email','$ip')";
$result = mysql_query($sql);
echo "thank you for your registration to cndalliance.com";
}

?>

Answer to PM:

Are you using free web hosting?

Try it in your local PC.

 

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'bludgeonaccount.db.4688039.hostedresource.com, bludgeonaccount, Greater99' (11004) in C:\xampp\htdocs\login2\do_reg.php on line 9
cannot connect

 

i did that on xampp same error... sorry guys i'm terrible at this lol... and im using go daddy.com as a hosting service... www.cndalliance.com/login2/registration.php

 

You have to change this on local PC:

Also input correct username, pass, db name in local Pc and try.

$host="localhost"; // Host name 
$username="bludgeonaccount"; // Mysql username 
$password="Greater99"; // Mysql password 
$db_name="bludgeonaccount"; // Database name 
$tbl_name="user"; // Table name

ok i got more of it to work :) YAY... there is hope after all ... ok enough of the good news... bak to my horrific problems lol... YOU GUYS ARE AWESOME BY THE WAY...

 

alright next up to bat..

 

its automatically echoing my check to see if all lines are filled. 2. it wont check my password check to see if they are the same... and i have an ip check on there and it wont show the ip for me... is my whole statment wrong and if so how should i rewrite it... one last question how do u chek and make sure that there is an at symbol in your email line

 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form 
$uname=$_POST['uname'];
$pw=$_POST['pw'];
$vpw=$_POST['vpw'];
$email=$_POST['email'];
$ip=$_POST['ip'];


// Insert data into mysql 
$sql="INSERT INTO $tbl_name(uname, pw, email, ip)VALUES('$uname', '$pw', '$email', 'ip')";
$result=mysql_query($sql);


if($name == false || $pass == false || $email == false) {
echo "Please fill in all the required fields.";
};
if($pass != $pass_conf){
echo "Passwords do not match.";
} else {

echo "thank you for your registration to cndalliance.com";

mysql_close();
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.