Jump to content

Doing a login page,keep getting http 500 error but i dunno what it mean!


ohguowei

Recommended Posts

hi, i'm new to php5 and mysql.

I'm doing this Login page everything work till i include the

 

"mysql_connect("localhost","root@localhost", "") or die("Failure to communicate with database!!!");"

 

as far as i can see. this is the area where the error happen. but i'm not sure whats the error is about.

Please help this confuse newbie...

 

<?php

$noform_var=0;

if ($_POST[ 'submit' ] == 'Submit') {

  if (!$_POST['UserName'] || $_POST['UserName'] == "" || strlen($_POST['UserName'] > 30 )){

    $message= '<p>There is a problem. Did you enter an user name?</p>';

    $noform_var = 1;

  }

  else{

    //open connection to the database

    $noform_var = 1;

     

      mysql_connect("localhost","root@localhost", "") or die("Failure to communicate with database!!!");

      mysql_select_db("user");

   

$as_UserName = addslashes($_POST['UserName']);

$as_UserPassword = addslashes($_POST['UserPassword']);

$as_UserEmail = addslashes($_POST['UserEmail']);

 

$tr_UserName = trim($as_UserName);

$tr_UserPassword = trim($as_UserPassword);

$tr_UserEmail = trim($as_UserEmail);

 

$query ="INSERT INTO USER_INFORMATION (USER_ID, USER_NAME, USER_PASSWORD, USER_EMAIL) VALUES (NULL, '$tr_UserName', '$tr_UserPassword', '$tr_UserEmail')";

$result = mysql_query($query);

 

if (mysql_affected_rows()==1){

  $message = "<p>Your information has been recorded. Please login and enjoy the game</p>";

  $noform_var = 1;

} else {

    error_log(sql_error());

    $message = "<p>Something went wrong with your signup attempt. Please email the admin for more information.</p>";

    $noform_var = 1;

}

}

}

 

//show the form in every case except successful submission

if(!$noform_var) {

  $thisfile = $_SERVER['PHP_SELF'];

  $message = <<< EOMSG

<FORM METHOD="post" ACTION="$thisfile">

<B>Your Name:<INPUT TYPE="TEXT" SIZE=25 NAME="UserName">

<BR><BR>

<B> Your PassWord:<INPUT TYPE="TEXT" SIZE=25 NAME="UserPassword">

<BR><BR>

<B> Your Email:<INPUT TYPE="TEXT" SIZE=25 NAME="UserEmail">

<BR><BR>

<INPUT TYPE="submit" NAME="submit" VALUE="Submit">

</form>

EOMSG;

}

 

?>

 

<html>

<head>

<STYLE type ="text/css">

<!--

BODY, p {color:black; font-family: verdana;font-size: 10 pt}

H! {color:n;acl; fpmt-family: arial; font-size:12 pt}

-->

</style>

<title>Login Page</title>

</head>

<body>

<table border=0 cellpadding=10 witdth=100%>

<tr>

<td bgcolor="#F0F8FF" align=center valign=top width=17%>

</td>

<TD bgcolor="#FFFFFF" align=left valign=top width=83%>

<h1> Newsletter sign-up form</h1>

<?php echo $message; ?>

</td>

</tr>

</table>

 

</body>

</html>

Link to comment
Share on other sites

ok i change the code abit and i got this message on my error log text. I'm still confuse on why the mysql_connect is undefined function... help please?

 

 

[Thu Sep 13 11:47:02 2007] [error] [client 127.0.0.1] PHP Notice:  Undefined index:  submit in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\Webpage\\LoginPage.Php on line 3

[Thu Sep 13 11:47:06 2007] [error] [client 127.0.0.1] PHP Fatal error:  Call to undefined function mysql_connect() in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\Webpage\\LoginPage.Php on line 12, referer: http://127.0.0.1/Webpage/LoginPage.php

 

 

Link to comment
Share on other sites

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.