Jump to content

cluce

Members
  • Posts

    354
  • Joined

  • Last visited

    Never

Posts posted by cluce

  1. I am baffled. Can someone tell me why the only output I receive in my email is the message: what ever submitted showed up. My name and email doesn't work???

     

    here is my code........

    <?php
    echo "<p>Thank you, <b>".$_POST["name"]."</b>, for your message!</p>";
    echo "<p>Your email address is: <b>".$_POST["email"]."</b>.</p>";
    
    //set up the mail
    $recipient = "cluce@mydomain.com";
    $subject = "Form Submission Results"; 
    
    //start building the mail string 
    $msg = "name: ".$_POST["name"]."\n";
    $msg = "email: ".$_POST["email"]."\n";
    $msg = "message: ".$_POST["message"]."\n";
    
    //send mail
    mail ($recipient, $subject, $msg);
    ?>

     

  2. I currently have a dynamic web site published over my work's domain but I am having trouble connecting to the database over the domain. Currently, mySQL is configured locally. Can someone tell me how to configured this so my coworkers can logon on to the database through their machine.

     

    Obviously, I have a connection issue....

     

    Fatal error: Call to undefined function mysqli_connect() in C:\Inetpub\wwwroot\email_info.php on line 8

     

    Any help is greatly appreciated.

  3. I currently have a dynamic web site published over my work's domain but I am having trouble connecting to the database over the domain. Currently, mySQL is configured locally. Can someone tell me how to configured this so my coworkers can logon on to the database.

     

    Obviously, I have a connection issue....

     

    Fatal error: Call to undefined function mysqli_connect() in C:\Inetpub\wwwroot\email_info.php on line 8

     

    Any help is greatly appreciated.

  4. I am trying to send mail in a web in a web form on a Windows XP machine and I receive this.....

     

    Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\sendmail.php on line 24

     

    Here are my settings..

    [mail function]

    ; For Win32 only.

    SMTP = localhost

     

    ; For Win32 only.

    sendmail_from = you@yourdomaim

     

    We don't use a mail server through our ISP at work.  We have our own mail server behind a proxy server. I am not sure how I configure this.  Would I use my company email serve to test this?

  5. my mistake on the code. :(

     

     

    this is what I have...

     

    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    }
    
    //connects to database
    $mysqli = mysqli_connect("localhost", "root", "", "test");
    
    //check to see if email exists in database/table
    $usercheck = stripslashes(trim($_POST['email']));
    $check = mysqli_query($mysqli,"SELECT email FROM auth_users WHERE email = '$usercheck' LIMIT 1"); 
    $check2= mysqli_num_rows($check);
    
    //if the email does not exist, it gives an error
    if ($check2 != 0) {
        echo ("email exists");
    
         //create and issue the query
         //$sql = "SELECT username, password FROM auth_users WHERE email = '".$_POST["email"]."';
         //$res = mysqli_query($mysqli, $sql);
        	
        //$to = "cluce@reaganpower.com";
    //$subject = "Website Inquiry Form";
    //$body = "$sql";
    //mail ($to, $subject, $body);
    //header("Location: http:reaganpower.com/thankyou.html");
    
    }else{
        $_SESSION['emailExists'] = "<font color='red'>The email"." ".$_POST['email']." "."does not exist in our database.<br>You may register for free by filling out the online registration form.</font>";	
    header ("Location: forgot_password.php");
    }
    
    mysqli_close($mysqli);
    ?>
    

     

  6. I am trying to error proof my web site but when I input a tag in the text field the tag still disrupts my web page. Can someone give me any suggestions?

    It looks like I am using the strip slashes function correctly. Is their some other code I need to add to this? My trim function works fine but not the strip slashes. I even took out the trim function and still no go.  ???

     

    here is my code

    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    }
    
    //connects to database
    $mysqli = mysqli_connect("localhost", "root", "", "test");
    
    //check to see if email exists in database/table
    $usercheck = strip_tags(trim($_POST['username']));
    $check = mysqli_query($mysqli,"SELECT email FROM auth_users WHERE email = '$usercheck' LIMIT 1"); 
    $check2= mysqli_num_rows($check);
    
    //if the email does not exist, it gives an error
    if ($check2 != 0) {
        echo ("email exists");
    
         //create and issue the query
         //$sql = "SELECT username, password FROM auth_users WHERE email = '".$_POST["email"]."';
         //$res = mysqli_query($mysqli, $sql);
        	
        //$to = "cluce@reaganpower.com";
    //$subject = "Website Inquiry Form";
    //$body = "$sql";
    //mail ($to, $subject, $body);
    //header("Location: http:reaganpower.com/thankyou.html");
    
    }else{
        $_SESSION['emailExists'] = "<font color='red'>The email"." ".$_POST['email']." "."does not exist in our database.<br>You may register for free by filling out the online registration form.</font>";	
    header ("Location: forgot_password.php");
    }
    
    mysqli_close($mysqli);
    ?>

  7. can someone tell me how to get rid of this error.......

     

    Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\wamp\www\fail.php on line 21

     

    here is my code.........

    <?php
    
    $mysqli = mysqli_connect("localhost", "root", "", "test");
    
    $sql = ("SELECT failed_logins FROM auth_users WHERE username = 'me'");
    $attempts = mysqli_query($mysqli, $sql);
    
    //disables user
    if ($attempts >= 3){
    echo ("login disabled");
    
    } else {
        echo ("its good");
    echo ("$attempts");
    }
    ?>
    

     

    when I ran this I got his...

    its good

    Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\wamp\www\fail.php on line 21

     

  8. now I have these....???

     

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, string given in C:\wamp\www\userlogin.php on line 21

     

    Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\userlogin.php:21) in C:\wamp\www\userlogin.php on line 63

     

     

    <?php
    session_start();
    
    //check for required fields from the form
    if ((!isset($_POST["username"])) || (!isset($_POST["password"]))) {
    	header("Location: user_logon.html");
    exit;
    }
    
    //connect to server and select database
    $mysqli = mysqli_connect("localhost", "root", "", "test");
    
    //create and issue the query
    $sql = "SELECT username, f_name, l_name FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')";
    
    $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
    
    //gets number of unsuccessful logins
    // Should be something like this...
    $sql1 = mysqli_query($mysqli,"SELECT failed_logins FROM auth_users WHERE username = '".$_POST["username"]."'");
    if (mysqli_num_rows($sql1) == 1) {
    $attempts = mysql_result($sql1, 0, 'failed_logins');
    } else {
    $attempts = 0;
    }
    //checks if user is disabled 
    if ($attempts >= 3){
    echo ("login disabled");
    
    } else {
    
    //get the number of rows in the result set; should be 1 if a match
    if (mysqli_num_rows($result) == 1) {
    
    //if authorized, get the values of f_name l_name
    while ($info = mysqli_fetch_array($result)) {
    	$f_name = stripslashes($info['f_name']);
    	$l_name = stripslashes($info['l_name']);
    }
    
    //set authorization cookie
    setcookie("auth", "1", 0, "/", "yourdomain.com", 0);
    $_SESSION['usersname'] = $f_name . " " . $l_name;
    
    //record last login
        $sql2 = "UPDATE auth_users SET last_login=NOW() WHERE username = '".$_POST["username"]."'";   
         mysqli_query($mysqli,$sql2);
    
    //clears failed logins
    $sql3 = "UPDATE auth_users SET failed_logins = 0 WHERE username = '".$_POST["username"]."'";
    mysqli_query($mysqli, $sql3);
    
    //directs authorized user
    header("Location: logon.php");
    
    } else {
    
    //redirect back to login form if not authorized
    $_SESSION['error'] =  "<font color='red'>invalid username and/or password combination</font>"; 
    $sql4 = "UPDATE auth_users SET failed_logins = failed_logins + 1 WHERE username = '".$_POST["username"]."'"; 
        mysqli_query($mysqli,$sql4);
      
    header("Location: user_logon.php");
    exit;
    }
    }
    ?>

  9. I am trying to disable a user from logging in if they have 3 or more failed_ login attempts stored in their record but the code is not displaying my message. Although it still counts the unsuccessful attempts and logs them in with correct username and password.

     

    can someomne see where the error is. I would appreciate it.

     

    here is my code....

    <?php
    session_start();
    
    //check for required fields from the form
    if ((!isset($_POST["username"])) || (!isset($_POST["password"]))) {
    	header("Location: user_logon.html");
    exit;
    }
    
    //connect to server and select database
    $mysqli = mysqli_connect("localhost", "root", "", "test");
    
    //create and issue the query
    $sql = "SELECT username, f_name, l_name FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')";
    
    $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));
    
    //gets number of unsuccessful logins
    $attempts = mysqli_query($mysqli,"SELECT failed_logins FROM auth_users WHERE username = '".$_POST["username"]."'");
    
    //checks if user is disabled 
    if ($attempts >= 3){
    echo ("login disabled");
    
    } else {
    
    //get the number of rows in the result set; should be 1 if a match
    if (mysqli_num_rows($result) == 1) {
    
    //if authorized, get the values of f_name l_name
    while ($info = mysqli_fetch_array($result)) {
    	$f_name = stripslashes($info['f_name']);
    	$l_name = stripslashes($info['l_name']);
    }
    
    //set authorization cookie
    setcookie("auth", "1", 0, "/", "yourdomain.com", 0);
    $_SESSION['usersname'] = $f_name . " " . $l_name;
    
    //record last login
        $sql2 = "UPDATE auth_users SET last_login=NOW() WHERE username = '".$_POST["username"]."'";   
         mysqli_query($mysqli,$sql2);
    
    //clears failed logins
    $sql3 = "UPDATE auth_users SET failed_logins = 0 WHERE username = '".$_POST["username"]."'";
    mysqli_query($mysqli, $sql3);
    
    //directs authorized user
    header("Location: logon.php");
    
    } else {
    
    //redirect back to login form if not authorized
    $_SESSION['error'] =  "<font color='red'>invalid username and/or password combination</font>"; 
    $sql4 = "UPDATE auth_users SET failed_logins = failed_logins + 1 WHERE username = '".$_POST["username"]."'"; 
        mysqli_query($mysqli,$sql4);
      
    header("Location: user_logon.php");
    exit;
    }
    }
    ?>

×
×
  • 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.