Jump to content

Laura555

Members
  • Posts

    8
  • Joined

  • Last visited

Laura555's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have just started trying to validate my register form on my website. I have entered the following code but it's not working so if anyone has any suggestions as to what I need to change, please let me know <form action='' method='POST'> <p><b>Name:</b><br /><input type='text' name='Name'/> <p><b>Phone No:</b><br /><input type='text' name='PhoneNo'/> <p><b>Password:</b><br /><input type='password' name='password'/> <p><b>Username:</b><br /><input type='text' name='username'/> <br> <br> <br> <p><input type='submit' class="submit_btn float_l" value='Register' /><input type='hidden' value='1' name='submitted' /> </form> <script type="text/javascript"> var frmvalidator = new Validator("register"); frmvalidator.addValidation("Name","req","Please enter your Name"); frmvalidator.addValidation("Name","maxlen=20", "Max length for Name is 20"); frmvalidator.addValidation("PhoneNo","maxlen=50"); frmvalidator.addValidation("PhoneNo","numeric"); frmvalidator.addValidation("password","req"); frmvalidator.addValidation("password","maxlen=20"); frmvalidator.addValidation("username","req"); frmvalidator.addValidation("username","maxlen=20"); validator.EnableOnPageErrorDisplay(); validator.EnableMsgsTogether(); </script>
  2. Thanks a million AyKay, that worked perfectly. Finally have it working!
  3. This is the code that I am now using. I'm getting an error for the " $username = mysql_real_escape_string($_POST['username']); //User Name sent from Form $password = mysql_real_escape_string($_POST['password']); // Password sent from Form" Its telling me they are undefined indices, how do I define them? include('config.php'); $username = mysql_real_escape_string($_POST['username']); //User Name sent from Form $password = mysql_real_escape_string($_POST['password']); // Password sent from Form $query = "select * from client where Username='$username' and Password='$password'"; $res = mysql_query($query); //Executing query and saving result in Result Set $rows = mysql_num_rows($res); if($rows==1) { $_SESSION['username']; header("location: Booking.php"); } else { echo 'Wrong login information. <br /> Re-Enter Username and Password'; } ?> <form action="?op=login" method="POST"> <p><b>Username:</b><br /><input type="text" name="Username" > <p><b>Password:</b><br /><input type="password" name="Password"><br /> <p><input type="submit" value="Login"> </form>;
  4. Thanks for the help Jacbey, I fixed those issues. I'm still getting the same errors- "Notice: Undefined index: Username in Login.php on line 73" and the same error for Password. Can't seem to figure out where I'm going wrong
  5. Sorry I got rid of that error but now I have other errors "Notice: Undefined index: Username in Login.php on line 73" and the same error for Password.
  6. On the web page an orange box appears saying "Parse error: syntax error, unexpected '}' in Login.php on line 94. But line 94 is just a '}'.
  7. Thanks so much for the help. Does this look any better, its still throwing errors- <?php session_start(); // dBase file include "config.php"; $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $q = "SELECT * FROM `client` WHERE `Username`= '$username' AND `Password`= '$passLIMIT 1"; $r = mysql_query($sql, $connection); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["Username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: Booking.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information."); } } else { //If all went right the Web form appears and users can log in echo "<form action=\"?op=login\" method=\"POST\">"; echo "<p><b>Username:</b><br /><input type=\"text\" name=\"Username\" >"; echo "<p><b>Password:</b><br /><input type=\"password\" name=\"Password\"><br />"; echo "<p><input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?>
  8. Hi I am creating a web based booking system using a WAMP server. I'm having trouble with the login form, the code doesn't seem to be reading from the database. I don't think it is a problem with the database itself as the it is connecting for my register and booking form. With the login form, everytime a user tries to login with valid credentials it just says 'sorry could not log you in, wrong log in information'. Heres the code: <?php session_start(); // dBase file include "config.php"; if (isset($_GET["op"]) == "login") { if (!$_POST["Username"] || !$_POST["Password"]) { ("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `client` " ."WHERE `Username`='".$_POST["Username"]."' " ."AND `Password`=PASSWORD('".$_POST["Password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["Username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: Booking.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information."); } } else { //If all went right the Web form appears and users can log in echo "<form action=\"?op=login\" method=\"POST\">"; echo "<p><b>Username:</b><br /><input type=\"text\" name=\"Username\" >"; echo "<p><b>Password:</b><br /><input type=\"password\" name=\"Password\"><br />"; echo "<p><input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?>
×
×
  • 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.