/    Sign up×
Community /Pin to ProfileBookmark

Help with our site

ok…….we made a login form..and we got it to where you can put ur info in and register…but when submit the info it says that “cannot connect to server” does anyone know what we might need to do to change this or what we did to cause this….thanks alot

to post a comment
PHP

17 Comments(s)

Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — the link is www.southtexprospects.com ......now....on the homepage there is a button under the about us button that isnt labeled..its just there..but thats were the register button is...if u need to see it visiully thats where it is..click it..and see what u think
Copy linkTweet thisAlerts:
@PSLohFeb 04.2005 — Pls post your codes on the register.php page
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — does nothkng show up?
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — there is code already in there....my friend is working on it..and says its there.....
Copy linkTweet thisAlerts:
@PSLohFeb 04.2005 — The issue is that from the page where you submit your form, you will be brought to register.php, where there will be some processing. I think the problem should be with register.php. Thats why I suggest you put up the codes for all to view and help.
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — here it is.....

<?

include 'db.php';

// Define post fields into simple variables

$first_name = $_POST['first_name'];

$last_name = $_
POST['last_name'];

$email_address = $_POST['email_address'];

$username = $_
POST['username'];

$info = $_POST['info'];

/* Let's strip some slashes in case the user entered

any escaped characters. *
/

$first_name = stripslashes($first_name);

$last_name = stripslashes($last_name);

$email_address = stripslashes($email_address);

$username = stripslashes($username);

$info = stripslashes($info);


/* Do some error checking on the form posted fields */

if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){

echo 'You did not submit the following required information! <br />';

if(!$first_name){

echo "First Name is a required field. Please enter it below.<br />";

}

if(!$last_name){

echo "Last Name is a required field. Please enter it below.<br />";

}

if(!$email_address){

echo "Email Address is a required field. Please enter it below.<br />";

}

if(!$username){

echo "Desired Username is a required field. Please enter it below.<br />";

}

include 'join_form.html'; // Show the form again!

/* End the error checking and if everything is ok, we'll move on to

creating the user account *
/

exit(); // if the error checking has failed, we'll exit the script!

}

/* Let's do some checking and ensure that the user's email address or username

does not exist in the database *
/

$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");

$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");

$email_check = mysql_num_rows($sql_email_check);

$username_check = mysql_num_rows($sql_username_check);

if(($email_check > 0) || ($username_check > 0)){

echo "Please fix the following errors: <br />";

if($email_check > 0){

echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />";

unset($email_address);

}

if($username_check > 0){

echo "The username you have selected has already been used by another member in our database. Please choose a different Username!<br />";

unset($username);

}

include 'join_form.html'; // Show the form again!

exit(); // exit the script so that we do not create this account!

}

/* Everything has passed both error checks that we have done.

It's time to create the account! *
/

/* Random Password generator.

http://www.phpfreaks.com/quickcode/Random_Password_Generator/56.php

We'll generate a random password for the

user and encrypt it, email it and then enter it into the db.

*/

function makeRandomPassword() {

$salt = "abchefghjkmnpqrstuvwxyz0123456789";

srand((double)microtime()*1000000);

$i = 0;

while ($i <= 7) {

$num = rand() % 33;

$tmp = substr($salt, $num, 1);

$pass = $pass . $tmp;

$i++;

}

return $pass;

}

$random_password = makeRandomPassword();

$db_password = md5($random_password);

// Enter info into the Database.

$info2 = htmlspecialchars($info);

$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, info, signup_date)

VALUES('$first_name', '$last_name', '$email_address', '$username', '$db_password', '$info2', now())") or die (mysql_error());

if(!$sql){

echo 'There has been an error creating your account. Please contact the webmaster.';

} else {

$userid = mysql_insert_id();

// Let's mail the user!

$subject = "Your Membership at MyWebsite!";

$message = "Dear $first_name $last_name,

Thank you for registering at our website, http://www.mydomain.com!

You are two steps away from logging in and accessing our exclusive members area.

To activate your membership, please click here: http://www.mydomain.com/activate.php?id=$userid&code=$db_password

Once you activate your memebership, you will be able to login with the following information:
Username: $username
Password: $random_password

Thanks!
The Webmaster

This is an automated response, please do not reply!";

mail($email_address, $subject, $message, "From: MyDomain Webmaster<[email protected]>nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';

}

?>
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — this is the db.php file...anyone know if we did this right??

<?

/* Database Information - Required!! */

/* -- Configure the Variables Below --*/

$dbhost = 'localhost';

$dbusername = '2003p';

$dbpasswd = '2004c';

$database_name = 'phpdir/index.php';

/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")

or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)

or die("Couldn't select database.");

?>
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — on teh local host...is that a folder..or would that be ftp.southtexprospects.com we arent sure what they are asking for
Copy linkTweet thisAlerts:
@PSLohFeb 04.2005 — I think the problem lies here:

$dbhost = 'localhost';

You should be providing the IP of your database host.
Copy linkTweet thisAlerts:
@BeachSideFeb 04.2005 — localhost is ok as long as that is where the database is.

Your problem is, if it is not connecting to the database, probably here...

$database_name = 'phpdir/index.php';[/quote]

that is calling a file and not a database
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — so exactly where do u point it to then?? is a web address?? if its not looking for a file then it has to be a addy....we'v tried everything....
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — if our database is called "reg" would we just simply put in "reg" or is it gonna be some long extension
Copy linkTweet thisAlerts:
@BeachSideFeb 04.2005 — if our database is called "reg" would we just simply put in "reg" or is it gonna be some long extension[/quote]

<?

/* Database Information - Required!! */

/* -- Configure the Variables Below --*/

$dbhost = 'localhost';

$dbusername = '2003p';

$dbpasswd = '2004c';

[SIZE=4][COLOR=red][b]$database_name[/b][/COLOR][/SIZE] = 'phpdir/index.php';

/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")

or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)

or die("Couldn't select database.");

?>


:rolleyes:
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — ok....thanks....on another part..someone mentions that our local host we would put in our database IP...anyway to find this?? i'v looked couldnt find it...would i just put the link that would direct it to our databases?
Copy linkTweet thisAlerts:
@BeachSideFeb 04.2005 — all localhost does is call from your server's default ip therfore you don't need to specify the ip.

Have you tried it yet with the proposed changes that have been mentioned in your numerous threads?

If you have and localhost is not working you will need to contact your host and find out what to use to connect to your database.
Copy linkTweet thisAlerts:
@PSLohFeb 04.2005 — You can get it from your web hosting provider...if it is also hosting your database...
Copy linkTweet thisAlerts:
@hsuballer42authorFeb 04.2005 — ok...they are...so im guessing just call them up and they should help us...awesome..aight...everyone thanks..and if you have input at all about what was talked about please post it...
×

Success!

Help @hsuballer42 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...