Jump to content

gingercrock

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gingercrock's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <html> <head> </head> <body> <BODY BGCOLOR="teal"> <left> <img src="http://users.cs.cf.ac.uk/S.J.Crocker/pictures/cardiff.bmp"> </left><br> <center> <img src="http://users.cs.cf.ac.uk/S.J.Crocker/pictures/reunited.bmp"> </center> <form method = "POST" action="members.html" onSubmit="returnverifyform(this)"> <h1> Please enter your password to use member only facilities: </h1> <br>Password: <input type = "password" name = "password"> <font color="black">*</font><br> <br><input type="submit" name = "enter" value = "Enter"> <input type="reset" name = "clear" value = "Clear"> <li><a href = "register.html">Register Free!!</a></li> <?php $connection = mysql_connect("sentinel.cs.cf.ac.uk","scm5sjc", "my password here"); $password=$_POST['password']; $errorMessage = ''; mysql_select_db("sjcdb",$connection) or die("failed!"); //keeb additions $query = "select * from users"; $result = mysql_query($query); $row = mysql_fetch_array($result) // end keeb additions.. if ($row) { if ($password == $row[9]){ header("Location:members.html"); } else { $errorMessage = 'Sorry, wrong user id / password'; echo $errorMessage; } ?> </body> Sorry, here is the query.. the password is in row 9 of the database.. thanks for your help, the screen simply goes blank now without any form at all...
  2. [b]Hey, I am a newbie, trying to produce a login form which will compare the user name and password entered by the user to a database in MySQL which contains a user name and password previously entered in a registration form. At the moment i have code which allows users to pass through to the 'members section' however.. it will allow a user with an invalid password to enter.. here is the code for the login html and php as i have written it:[/b] <html> <head> </head> <body> <BODY BGCOLOR="teal"> <left> <img src="http://users.cs.cf.ac.uk/S.J.Crocker/pictures/cardiff.bmp"> </left><br> <center> <img src="http://users.cs.cf.ac.uk/S.J.Crocker/pictures/reunited.bmp"> </center> <form method = "POST" action="members.html" onSubmit="returnverifyform(this)"> <h1> Please enter your password to use member only facilities: </h1> <br>User Name: <input type = "text" name = "user_name"> <font color="black">*</font><br> <br>Password: <input type = "password" name = "password"> <font color="black">*</font><br> <br><input type="submit" name = "enter" value = "Enter"> <input type="reset" name = "clear" value = "Clear"> <li><a href = "register.html">Register Free!!</a></li> <?php $connection = mysql_connect("sentinel.cs.cf.ac.uk","scm5sjc", "**MY PASSWORD HERE**"); $password=$_POST['password']; $user_name=$_POST['user_name']; $errorMessage = ''; mysql_select_db("sjcdb",$connection) or die("failed!"); if ($row) { if ($password == $row[9]){ header("Location:members.html"); } else { $errorMessage = 'Sorry, wrong user id / password'; echo $errorMessage; } } mysql_close(); ?> </body> </html> [b]Any help would be great, cheers[/b]
  3. thanks, the first post has been edited. the new code still leaves the screen blank unfortuantly. i have entered some more code so now we have : <?php $connection = mysql_connect("sentinel.cs.cf.ac.uk","User_Name", "PASSWORD"); $first=$_POST['first']; $second=$_POST['second']; mysql_select_db("sjcdb",$connection) or die("failed!"); echo $first; echo $last; $query = "SELECT * FROM info WHERE first='$first' AND last ='$second'"; echo $query; $result = mysql_query($query, $connection); while($row = mysql_fetch_row($result)) { $title = $row[2]; $first = $row[3]; $last = $row[4]; echo $title." ".$first." ".$last.; } mysql_close($connection); ?> If it helps, MySQL database has field names 'title', 'first' and 'last' and there is a field before this which is an increment 'ID'. title,first and last are in rows 1,2 and 3 respectively.. i had it working a day or two ago but tryed to changed around abit of code, got it wrong and the back up has been wiped!! so frustration is at its highest! thanks for your help, i hope this information is of some use! Steven
  4. Hey guys, i am having problems while searching for members on my website.. i have a form that users fill in before being able to click on a 'search' button.. which works and the code is: [i]<form method = "POST" action="searchName.php" onSubmit="returnverifyform(this)"> <br>First name: <input type ="text" name = "first"> <font color = "black"></font> <br>Last name: <input type = "text" name = "second"> <font color="black"></font> </select><input type="submit" value = "Search">[/i] it then opens 'searchName.php' which is meant to search through a database that i have created online.. the code is below: [i]<?php $connection = mysql_connect("sentinel.cs.cf.ac.uk","user_name", "password"); $first=$_POST['first']; $second=$_POST['second']; mysql_select_db("sjcdb",$connection) or die("failed!"); echo $first; echo $last; $query = "SELECT * FROM info WHERE first='".$first."' AND last ='".$second."'"; echo $query; $result = mysql_query($query, $connection); while($row = mysql_fetch_row($result)) { $title = $row[2]; $first = $row[3]; $last = $row[4]; echo "$title." ".$first." ".$last."; } mysql_close($connection); ?>[/i] However, the screen simply is left blank.. any ideas where im going wrong? i am a newbie im afraid so i apologise for any schoolboy errors!! thanks for your time steven
  5. hey, i am currently building a basic website to get the feel for using mySql and so on.. i have a registration form from which i wish the data entered by the user to enter into a database i have.. however, i have tried various different attempts to get this working but i am failing each time.. here is my code: [i]<?php $connection = mysql_connect("sentinel.cs.cf.ac.uk","scm5sjc","my_password_here"); mysql_select_db("sjcdb",$connection)or die("failed!"); $title="title"; $first="first"; $last="last"; $age="age"; $subject="subject"; $year="year"; $email="email" mysql_query("INSERT INTO info values('NULL', '$title','$last','$age',$subject','$year','$email')",$connection); mysql_close(connection); ?>[/i] This page is named 'display.php' and is linked up by the registration form 'main.php'.. once the submit button is pressed, however on the website "https://www.cs.cf.ac.uk/phpMyAdmin/index.php" where my database is, no data is entered.. any help would be great!!! thanks Steven
  6. hey guys, i am doing a project at the moment which is basically a friends reunited type of website.. i have created a database but the searches do not work.. this is the code i have for when the 'search' button is pressed: <?php $connection = mysql_connect("sentinel.cs.cf.ac.uk","scm5sjc", "put_password_here"); mysql_select_db("sjcdb",$connection) or die("failed!"); $result = mysql_query("SELECT * FROM info", $connection); while($row = mysql_fetch_row($result)) { $title = $row[1]; $first = $row[2]; $last = $row[3]; $age = $row[4]; $subject = $row[5]; $initial=$row[6]; $email=$row[7]; for ($i=0; $i<mysql_num_fields($result); $i++) print $row[$i]." "; echo "\n"; print $title." "; print $first." "; print $last ." "; print $age ." "; print $subject." "; print $initial." "; print $email." "; } mysql_close($connection); ?> </pre> all that appears when the button is pressed is this code, any advice of where i may have gone wrong would be great, thanks. steve
×
×
  • 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.