Jump to content

jardane

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jardane's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i am making two mySQL query's pulling information from two different tables: $q = "SELECT zip FROM allowed_zip WHERE user_id='$id'"; and $z = "SELECT zip_code FROM companies WHERE ". $search; $search is just a selection sting i build before hand ignore that part. What i need to do is to have an if statement is to check if the values pulled in to $z exist in $q. They are both lists of zip codes, the first one is a list of zip code the user has access too and the second one is what the user is searching for. This is meant to deny them access to select records.
  2. I have an input box for a zip code and i need error code to check if it contain 5 digits and contains only numbers.
  3. i feel so stupid i was saving the password to the database without using SHA1 but when i was doing my select statement i was using SHA1 it all works now.
  4. i feel so stupid i was using SHA1 for the password but the password was not saved to the database using SHA1 so it was not matching. It works now thanks everyone.
  5. I still can't get it to work here is the whole code: <?php include("head_start.php"); echo '<title>Densar Data Information - Login</title>'; include("head_end.php"); ?> <?php $errors = array(); require_once ('mysqli_connect.php'); // Connect to the db. if (isset($_POST['submitted'])) { //email if (empty($_POST['email'])) { $errors[] = 'You forgot to enter your email.'; }else { $e = mysqli_real_escape_string($dbc, trim($_POST['email'])); } //password if (empty($_POST['password'])) { $errors[] = 'You forgot to enter your password.'; }else { $p = mysqli_real_escape_string($dbc, trim($_POST['password'])); } if (empty($errors)) { // If everything's OK. $q = "SELECT user_id, first_name FROM users WHERE email='$e' AND pass=SHA1('$p')"; $r = @mysqli_query ($dbc, $q); // Run the query if (!empty($r)) { $row = mysqli_fetch_assoc($r); $_SESSION['user_id'] = $row['user_id']; $_SESSION['first_name'] = $row['first_name']; $_SESSION['email'] = $_POST['email']; $_SESSION['password'] = $_POST['password']; $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']); echo $row['user_id']; require_once ('redirect_user_profile.html'); } }else{ include("head_start.php"); include("head_end.php"); echo '<h1>Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; // End of if (empty($errors)) IF. include("admin_form.html"); } mysqli_close($dbc); // Close the database connection. }else{ echo "<h1>Admin Login</h1>"; include("admin_form.html"); } ?> <?php include("footer.html");?>
  6. both $f = $r->fetch_assoc(); and mysqli_fetch_array don't work
  7. yes i saw that and corrected it before you even fixed the mistake. here is the whole code: $q = "SELECT user_id, first_name FROM users WHERE email='$e' AND pass=SHA1('$p')"; $r = @mysqli_query ($dbc, $q); // Run the query if (!empty($r)) { $f = mysql_fetch_array($r); $_SESSION['user_id'] = $f['user_id']; $_SESSION['first_name'] = $f['first_name']; $_SESSION['email'] = $_POST['email']; $_SESSION['password'] = $_POST['password']; $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']); //require_once ('redirect_user_profile.html'); } And the error is: Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\xampp\htdocs\test_server\login.php on line 28 and for reference line 28 is: $f = mysql_fetch_array($r);
  8. ok now it's giving me an error Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\xampp\htdocs\test_server\login.php on line 27
  9. Thanks i am really starting to love this forum
  10. i have a mySQL login script that pulls a single record from my database. $q = "SELECT user_id, first_name FROM users WHERE email='$e' AND pass=SHA1('$p')"; $r = @mysqli_query ($dbc, $q); // Run the query What i need is to pull the values from user_id and first_name or what ever information i want from that single record and store it in session variables like. $_SESSION['user_id'] = user_id It's easy when your working with a lot of records but i have no idea how to pull from just one.
  11. DavidAM your code worked great thanks a ton!!!
  12. The echo of the select statement is: SELECT `name`, `site_address`, `site_city`, `state`, `zip_code`, `telephone`, `mailing_address`, `transporter`, `desginated_facility`, `us_dot`, `quantity`, `wast_code`,`offerers_name`, `manifests` FROM `companies` WHERE quantity='$qu' $search is made with this script: for ($i = 0; $i < $count; $i++) { $search = $search . $find[$i]; } And the $find array is set using: if (!empty($_POST['quantity'])) { if ($count == 0){ $find[$count] = " quantity='\$qu'"; $qu = mysqli_real_escape_string($dbc, trim($_POST['quantity'])); $count ++; }else{ $find[$count] = " AND quantity='\$qu'"; $qu = mysqli_real_escape_string($dbc, trim($_POST['quantity'])); $count ++; } } There is one of these for each search option.
  13. I have a program where i have my text box's where the user can enter search terms. The user is only required to enter at least one but has the option to enter up to 14. I tried this: $q = "SELECT `name`, `site_address`, `site_city`, `state`, `zip_code`, `telephone`, `mailing_address`, `transporter`, `desginated_facility`, `us_dot`, `quantity`, `wast_code`,`offerers_name`, `manifests` FROM `companies` WHERE " . $search; I build $search to include what i want searched for depending on what the user wants to search for. But this is not working and i know for sure that it's the select statement. Can someone give me a hand or tell me another way of doing this?
×
×
  • 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.