Jump to content

Search the Community

Showing results for tags 'msqli'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. Hello Guys My code runs fine but value null is inserting if some one dint select any list name . So wot i want if some one did not select any option query did not run $error shows Here is my code please check and figure it out <?php $error=""; include "db.php"; if(isset($_POST['bt'])){ $date=Date("Y-m-d H:i:s"); $b=$_POST['name']; $res=$_POST['res']; if(!$_POST["res"]){ } if(!$_POST["name"]){ } // Declare variable if(!$_POST["name"] or ["name"] == '' ) { $error .= "Must select the name.<br />";// If not selected, add string to error message } if(!$_POST["res"] ){ $error .= "Must Enter the Reason.<br />"; // If not Enter, add string to error message } else{ $sq="insert into att(name,date,res)values('$b','$date','$res')"; $sq1=mysqli_query($a,$sq); echo "Ok"; // } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title></title> <link rel="stylesheet" href=""> </head> <body> <form action="pres.php" method="post" accept-charset="utf-8"> <select name="name" > <option value="" >Choose...</option> <option value="mandeep" >Maneep</option> <option value="sahiba" >Sahiba</option> </select> </select> <input type="text" name="res"> <input type="submit" name="bt" value="Ok"> <br> <?php echo"". $error;?> </form> </body> </html>
  2. I need my user to log in to use their "admin panel" functions. I have this bit of html for them to enter their username/password: <form id="form1" name="form1" method="post" action="functions/loginprocess.php"> <table> <tr> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" id="username" /></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="button" id="button" value="Login" /></td> </tr> </table> </form> This bit of code at the top of the html to start the session: <?php session_start(); $err = $_GET['e']; ?> This bit of code at the top of the index page to redirect to the login screen <?php session_start(); $l=6; $a="out"; if(isset($_SESSION['username'])) { $l=$_SESSION['username']; $a="in"; } else { header('Location: login.php?e=Login to use the administration functions'); } $err = $_GET['e']; ?> And this code to perform the log in functions: <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; $conn = mysqli_connect("Connection String"); $username = mysqli_real_escape_string($conn, $username); $query="SELECT * FROM users WHERE username='$username' AND userpassword='$password'"; $result = mysqli_query($conn, $query); if(mysqli_num_rows($result) == 0) // User not found. So, redirect to login_form again. { $conn->close(); header('Location: ../login.php?e=User not found'); exit(); } $userData = mysqli_fetch_array($result); $hash = hash('sha256', $userData['cmspassword']."$password"); //echo "$hash"; if($hash != $userData['userpassword']) // Incorrect password. So, redirect to login_form again. { $conn->close(); header('Location: ../login.php?e=Incorrect login details'); exit(); } else{ // Redirect to home page after successful login. $_SESSION['username'] = $username; $_SESSION['user'] = $userData['userid']; $_SESSION['sp'] = $userData['cmspassword']; $conn->close(); header('Location: ../index.php'); exit(); } ?> And the database table is called 'users' with the following columns: userid username useremail userpassword cmspassword However, as stated in the title of this post, I appear to be stuck in a loop where whenever I enter the user credentials it just keeps looping round the "user not found" message on line 16. Can anyone help me, I am well and truly stuck on how to get out of this loop? I know I've gone wrong somewhere, just can't see where
×
×
  • 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.