login to select code

Discussion in 'PHP' started by dougvcd, Jul 11, 2008.

  1. #1
    is it possable to have a simple input form where peeps put there email addy and password in and then using a variable such as
    
    $data = mysql_query("select * from phonebook where email= ? and password= ?");
    
    PHP:
    in this code for select

    
    // Get all records in all columns from table and put it in $result.
     $data = mysql_query("select * from phonebook");
    if(mysql_num_rows( $data ) == 0) {
         echo 'No Results';
     } else {
     echo "<table>";
    while($info = mysql_fetch_array($data))
    {
    
    
    // Output
    echo "<tr>
    		  <td>". $info['id'] ."</td>
              <td>". $info['name'] ."</td>
    		  <td>". $info['username'] ."</td>
              <td>". $info['email'] ."</td>";
       echo '<td><a href="update.php?id='.$info['id'].'">Update</a></td>';
       echo '<td><a href="delete.php?id='.$info['id'].'">Delete</a>';
    
       echo "</tr>";
    }   
     
    echo "</table>";  
    
    }
    
    ?> 
    
    PHP:
    if you see what i mean
    cheers
    Doug
     
    dougvcd, Jul 11, 2008 IP
  2. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Put this in inputform.php

    
    <html><body>
    <form name="form1" method="post" action="doprocess.php">
    <input name="email" type="text" id="email">
    <input name="password" type="text" id="password">
    <input type="submit" name="Submit" value="myinput">
    </form>
    </body>
    </html>
    PHP:
    Put this in doprocess.php

    $email = mysql_real_escape_string($_POST['email']); 
    $password = mysql_real_escape_string($_POST['password']);
    $data = mysql_query("select * from phonebook where email='$email' and password='$password'");
    // ... continue with the code after $data = ....
    
    PHP:
    I hope this helps.
     
    revvi, Jul 11, 2008 IP
  3. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    big thanks
    that all works fine
    cheers
    Doug
    :)
     
    dougvcd, Jul 11, 2008 IP
  4. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You're welcome. Glad can help. :)
     
    revvi, Jul 11, 2008 IP