Jump to content

JakkyD

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by JakkyD

  1. Not sure if it's the same for postgresql but for MySQL I do this: Column name = password Data type = VARCHAR(32) And then in PHP: $Password = $_POST["Password"]; $Password = md5($Password);
  2. Hello, I have a booking system which has time and date fields and if someone tries to book, for example, on 01/01/2011 at 09:00, when this slot is already taken, an error would be produced - which is fine. However I'm not sure in telling them what hours are available. There are 9 available times: 09,10,11,12,13,14,15,16,17:00. I will need to perform an sql query to gather all the times on the inputted date, I'm guessing a for loop would be the most efficient way? The only way I could think of is using multiple IF queries, for example: <?php $sql = "SELECT `Hour` FROM `jobs` WHERE `Hour` = '09:00:00' AND Day ='$Day' AND Month ='$Month' AND Year ='$Year'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0){ $09Available = 'n'; // Time not available }else{ $09Available = 'y'; } $sql = "SELECT `Hour` FROM `jobs` WHERE `Hour` = '10:00:00' AND Day ='$Day' AND Month ='$Month' AND Year ='$Year'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0){ $10Available = 'n'; // Time not available }else{ $10Available = 'y'; } $sql = "SELECT `Hour` FROM `jobs` WHERE `Hour` = '11:00:00' AND Day ='$Day' AND Month ='$Month' AND Year ='$Year'"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0){ $11Available = 'n'; // Time not available }else{ $11Available = 'y'; } ?> etc. etc.. How would I go about creating a more efficient method? Thank you, Jack.
  3. "and if" is not a valid expression. Use "&&" to represent AND <?php if (($a==1) && ($b==2) ) { // code } ?> ----> <?php if ((mysql_num_rows($discountcodecheck) > 0) && (mysql_num_rows($remainingusescheck) > 0)) ?> Should work, not sure if I've got the brackets wrong though
  4. Yes at home I'm running Windows 7 whereas the school is running XP. Linux for the web hosting I think :/ I've unset read-only to the whole xampp folder and that didn't change anything. no, not necessarily. whether register_globals is on, path differences between windows/non-windows, there are lots of things that can change between installations. we'd need to see code to try to help troubleshoot the problem. regardless, if you don't have this at the top of your script, it might help spot any unexpected problems error_reporting(E_ALL); ini_set("display_errors", -1); I've just looked at phpinfo() and register_globals is off for my home network. I assume this should be set to on? How do I do this? Thanks both of you. Edit - I've looked at my schools phpinfo() and register_globals is also off so I now assume this isn't the problem. There isn't much to the code: LoginDo.php <?php $con = mysql_connect("localhost","root",""); //Connect to database if (!$con) { die('Could not connect: ' . mysql_error()); //Produces error if database connection is unsuccessful } mysql_select_db("database",$con); // Define $Email and $Password $Email=$_POST['Email']; $Password=$_POST['Password']; // To protect MySQL injection (more detail about MySQL injection) $Email = stripslashes($Email); $Password = stripslashes($Password); $Email = mysql_real_escape_string($Email); $Password = mysql_real_escape_string($Password); $Password=md5($Password); $sql="SELECT * FROM customers WHERE Email='$Email' and Password='$Password'"; $result=mysql_query($sql); $query_row=mysql_fetch_array($result); $CustomerID = $query_row[CustomerID]; $Forename = $query_row[Forename]; // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $Email and $Password, table row must be 1 row if($count==1){ // Register $Email, $Password and redirect to file "LoginSuccessful.php" session_start(); $_SESSION["LoggedIn"] = '1'; $_SESSION["CustomerID"] = $CustomerID; $_SESSION["Forename"] = $Forename; $_SESSION["Email"] = $Email; header("location:LoginSuccessful.php"); } else { echo "Wrong Email Address or Password"; } ?> LoginSuccessful.php <?php session_start(); if(!$_SESSION["LoggedIn"] == '1'){ header("location:index.php"); } $Email = $_SESSION["Email"]; $CustomerID = $_SESSION["CustomerID"]; $Forename = $_SESSION["Forename"]; ?> <html> <body> Login Successful <?php echo "Welcome"; echo $Email; echo $_SESSION["CustomerID"]; echo $_SESSION["Forename"]; echo $CustomerID; echo $Forename; ?> </body> </html> (I was just messing around in this file seeing if I could echo the SESSIONS and its variables) Both these files work fine on the schools system
  5. My school is running PHP 4.3.2 on its network, and I'm running PHP 5.3.1 on my localhost machine using Xampp/Apache. My login system works perfectly at school, however $_SESSION["LoggedIn"] does not register, recognise nor acknowledge on my home system. It's not the script itself as I've copied the files across, so in theory it should work exactly the same? I've compared phpinfo()'s and within the session category all values are the same. The database/MySQL works fine on both networks so it's not a problem to do with this. Any ideas? Thanks.
×
×
  • 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.