Jump to content

ohguowei

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ohguowei's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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
  2. 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>
  3. hey i got it to work! its the logic itself that is having problem. i keep asking the code to run everything in one IF, that why it doesnt work ! thanks for the help even if its not the answer i'm looking for.
  4. i try running the code with $message defined on the top of the script but i didnt get the FORM that i wanted. Why should i define the $message on the top of the script? and why doesnt the FORM INPUT display on the page? Is the logic of my coding wrong in the first place? Some more help please? 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; }
  5. Hi i'm a newbie to PhP and i'm doing a webpage login with php5, mysql4 and apache2.2.4. I copy this code from a book and change some of the code a bit. When i try to run it gave me "PHP Notice: Undefined variable: message in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Webpage\LoginPage.Php on line 70" Its the last line of the code "<?php echo $message; ?>" Why is it undefined? i'm confused. Please help <?php 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>'; } else{ //open connection to the database mysql_connect("localhost","root","") or die("Failure to cmmunicate 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>"; } } //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>
×
×
  • 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.