Jump to content

vikram12345

Members
  • Posts

    22
  • Joined

  • Last visited

Posts posted by vikram12345

  1. Hi people. 

    This problem may be a stupid one.

     

    I'm totally new @ this. 

     

    Okay, here I go. I'm coding this PHP website, where every page is loaded by accepting values through the URL. Eg. -> xyz.com/view_content.php?id=1234&limit=674 

     

    The entire theme of the page changes everytime I enter id and limit values. Is there any way I could reduce the URL to a shorter one like

     

    xyz.com/cool-blue OR xyz.com/eternal-red . so when a user types one of these it points to xyz.com/view_content.php?id=1234&limit=674  or something else.

     

    MY AIM is to store these values in a SQL table. Also the final URL should not be visible in the address bar. 

  2. SELECT * FROM 

    You have only two fields in that table? If not, then this won't work:

    $stmt->bind_result($email,$hash);

     

    Always define the fields you want to retrieve from the database, and avoid using the "*" (all) selector. Not only for performance issues, but also because you'll avoid situations like these.

     

    really sorry for buggin you guys, but what can I replace it with ?

    any other changes required in the code ??

  3. That post from annarocco39 is just spam.

     

    Your error msgs :

    1st one :

    $stmt->bind_param("ss",$email, $hash);

    You are sending 3 paramaters to the query sting when you have only put 2 ? holders in place in the query string.

     

    2nd and 3rd both relate to

    $row_cnt = $result->num_rows

    You have not defined $result as anything previous to this line. You have to define a variable before you can use it on the tight hand side of an assignment.

    As the parser does not know what $result is, it can't access the object properties you think it should have.

     

     

    I solved the result issue .

     

    Now i'm gettin this

     

    Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in D:\xampp\htdocs\bullet2\sqlilogincheck.phpon line 39

     

    my current code :

     

    // $goto = $_GET['goto'] ;
    session_start() ;
    $useremail = $_POST['emailfield'] ;
    $passwording = $_POST['pwfield'] ;
    
    $salt = "@cmiplpnp##" ;
    $iterations = 4;
    $hash = crypt($passwording,$salt);
    for ($i = 0; $i < $iterations; ++$i)
    {
       $hash = crypt($hash . $passwording,$salt);
    }
    
    echo $passwording ;
    echo '<br>' ;
    echo $hash ;
    echo '<br>' ;
    require ('sqliauth2.php') ;
    /* create a prepared statement */
    if ($stmt = $mysqli->prepare("SELECT * FROM userregistry WHERE email= ? AND password11=? ")) ;
    {
    
    
       /* bind parameters for markers */
       $stmt->bind_param("ss",$email, $hash);
    
    
       /* execute query */
       $stmt->execute();
    
    
    
    
       /* bind result variables */
       $stmt->bind_result($email,$hash);
       $stmt->fetch();
    
       $row_cnt = $stmt->num_rows ;
       /* close statement */
       $stmt->close();
    }
    
    
    /* close connection */
    $mysqli->close();
    
    
    echo $row_cnt ;
    
    
    ?>
    

  4. 
    <?php
    
    
    // $goto = $_GET['goto'] ;
    session_start() ;
    $useremail = $_POST['emailfield'] ;
    $passwording = $_POST['pwfield'] ;
    
    
    
    
    $salt = "@cmiplpnp##" ;
    $iterations = 4;
    $hash = crypt($passwording,$salt);
    for ($i = 0; $i < $iterations; ++$i)
    {
       $hash = crypt($hash . $passwording,$salt);
    }
    
    echo $passwording ;
    echo '<br>' ;
    echo $hash ;
    echo '<br>' ;
    require ('sqliauth2.php') ;
    /* create a prepared statement */
    if ($stmt = $mysqli->prepare("SELECT * FROM userregistry WHERE email= ? AND password11=? ")) ;
    {
    
       /* bind parameters for markers */
       $stmt->bind_param("ss",$email, $hash);
    
       /* execute query */
       $stmt->execute();
    
    
    
       /* bind result variables */
       $stmt->bind_result($email,$hash);
       $stmt->fetch();
       $row_cnt = $result->num_rows ;
       /* close statement */
       $stmt->close();
    }
    
    /* close connection */
    $mysqli->close();
    
    echo $row_cnt ;
    
    ?>
    
    

     

    ERRORS ::::

     

    Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in D:\xampp\htdocs\bullet2\sqlilogincheck.phpon line 39

     

    Notice: Undefined variable: result in D:\xampp\htdocs\bullet2\sqlilogincheck.php on line 41

     

    Notice: Trying to get property of non-object in D:\xampp\htdocs\bullet2\sqlilogincheck.php on line 41

     

     

    Trying to understand why, but no clue :(

    HELP !!!

  5. <?php

    /* create a prepared statement */

    if ($stmt = $mysqli->prepare("INSERT INTO userregistry (email,password11,firstname,lastname,contact,sex,dob,active,date) VALUES (?,?,?,?,?,?,?,?,?)"))

    {

     

    /* bind parameters for markers */

    $stmt->bind_param("sssssssss", $email , $hash, $firstname , $secondname , $contact , $sex ,$dob , $active , $date);

     

    /* execute query */

    $stmt->execute();

     

     

     

    /* bind result variables */

    $stmt->bind_result($email,$hash,$firstname,$secondname,$contact,$sex,$dob,$active,$date);

    $stmt->fetch();

     

    /* close statement */

    $stmt->close();

    }

     

    /* close connection */

    $mysqli->close();

    ?>

     

     

    Well this is the code I've written to enter the above fields into a DB

     

    I keep getting the error

     

     

    Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in D:\xampp\htdocs\bullet2\sqlienterintodb.phpon line 15

     

     

    Any ideas ??

  6. My user authentication code --

     

     

    <?php

     

    $useremail = $_POST['emailfield'] ;

    $userpassword = $_POST['pwfield'] ;

     

    require ('sqlauth2.php') ;

    mysql_select_db($database, $con);

    $sql = "SELECT * FROM userregistry WHERE email='".$useremail."' AND password='".$userpassword."'" ;

    $run = mysql_query($sql) ;

    $row = mysql_fetch_array($run) ;

     

    if(mysql_num_rows($run) == 1)

    {

    echo "SUCCESS :) <br>" ;

    }

    else

    {

    echo "No login for you :( " ;

    }

     

     

     

    ?>

     

     

     

    Looks perfect, but I keep getting this error

     

     

    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\bullet2\logincheck.php on line 10

     

    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\bullet2\logincheck.php on line 12

    No login for you :(

     

     

    Any idea ?

    Searched everywhere, couldn't find anything proper.

    I know there is something wrong somewhere, can't seem to find it.

    Help me out people, thanks !!!

  7. Alright, here it is :

     

    before addintodb.php

    I run sqlauth.php

     

    Since I'm runnin sql w/o a password, the $password from the form and $password from the auth file conflict.

    Thereby the $password sets to null .

    change sql $password to $passworda or whatever and conflict resolved :)

  8. Any bets that you are trying to check if it is empty, but are actually assigning an empty string to it?

     

    It doesn't get assign empty. echoed $password right before mysql query. displays the value fine

    anything wrong with the mysql code ?

  9. <?php

    date_default_timezone_set('Asia/Kolkata') ;

    $estatus = 0 ;

    $erepeatstatus = 0 ;

    $passwordstatus = 0 ;

    $repeatpasswordstatus = 0 ;

    $date = date("F j, Y, g:i a");

    $active = 1 ;

    $blankemail = 0 ;

    $blankpassword = 0 ;

    $allokay = 0 ;

    if (strlen($email)==0)

    {

    $blankemail = 2 ;

    }

    else

    {

    $blankemail = 1 ;

    }

     

    if (strlen($password)==0)

    {

    $blankpassword = 2 ;

    }

    else

    {

    $blankpassword = 1 ;

    }

     

    if(!filter_var($email, FILTER_VALIDATE_EMAIL))

    {

    $estatus = 2 ;

    }

    else

    {

    $estatus = 1 ;

    }

     

    if($emailtwo == $emailtwo)

    {

    $erepeatstatus = 1 ;

    }

    else

    {

    $erepeatstatus = 2 ;

    }

     

     

    if (strlen($password)<= 10)

    {

    $passwordstatus = 1 ;

    }

    else

    {

    $passwordstatus = 2 ;

    }

     

    if($password == $passwordtwo)

    {

    $passwordrepeatstatus = 1 ;

    }

    else

    {

    $passwordrepeatstatus = 2 ;

    }

     

    echo $email."<br>" ;

    echo $emailtwo."<br>" ;

    echo $password."<br>" ;

    echo $passwordtwo."<br>" ;

    //echo intval($email);

     

     

    $allokay = $blankemail.$blankpassword.$estatus.$erepeatstatus.$passwordstatus.$passwordrepeatstatus ;

    echo $allokay ;

    if($allokay == 111111)

    {

    require ('sqlauth2.php') ;

    require ('enterintodb.php') ;

    echo "new user registered " ;

    }

    else

    {

    $goto = "http://localhost:78/bullet2/newuserregister.php?blankemail=".$blankemail."&blankpassword=".$blankpassword."&emailformat=".$estatus."&emailrepeat=".$erepeatstatus."&longpassword=".$passwordstatus."&passwordrepeat=".$passwordrepeatstatus ;

    header("Location: $goto ");

    }

    exit ;

     

    ?>

  10. as you can see

     

    INSERT INTO userregistry (email,password11,firstname,lastname,contact,sex,dob,active,date) VALUES ('vikram12345@gmail.com','','cv','sd','9535283163','1','01012000','1','November 17, 2012, 10:53 pm')

     

    ^ the echoed sql query

  11. Exactly. Immediately after defining the $sql variable, and before executing the query.

     

    Alright, looks like we're getting somewhere.

    echoed the query, the insert password value turns blank for some reason .

    Any idea ?, all other inserts have solid values, only the pw value disappears during query

  12. You have either:

    1. spelling error in your column names.

    2. spelling error in your variable name.

     

    Well, I don't seem to have a variable spelling error, seems to me the echo wouldn't have worked at all.

    No column spelling error either, double checked both. I'm running on Xampp, with phpmyadmin .

    restarted MySql twice, no progress there either . :sweat: Any other way this could happen ?. Collation problems ?, any special setting for MySql to handle password fields ??

  13. Hi,

    I'm not new to Sql or PHP or atleast I hope not :happy-04: . I coded a simple register form in HTML and this file opens a 'newuser.php' which in turn opens another one, and another finally after checking all INPUT fields, reaches a 'enterintodb.php' .

     

    Now, here's the joke. Every field enters into the table of MySql except for the password field. All entries including 1st name, last name, etc etc. get added to the table and like I said , password doesn't add.

     

    Just to be sure, at the end I echo all the fields and then echo "New user created !" .

     

    No MySql error or any syntax error displayed. The password field echoes w/o any problems, it displays the entered password. But no entry in the DB .

     

    password column : varchar(255) , utf16_general_ci ,

     

    Iv also attached the enterintodb.php file .

    the others don't matter, coz when I echo $password, it displays perfectly.

     

    in the form this is the password field " <input type="password" name="password" size="20" style="border-left-width=0px"> "

     

    and don't worry about sql auth, i run a separate PHP file for that before enterintodb.php

     

    So, guys, help me out :) please

     

    Here's the attachment = enterintodb.php

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