Jump to content


Photo

PHP/MySQL Help (rows)


  • Please log in to reply
4 replies to this topic

#1 esahp

esahp
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationUSA

Posted 26 September 2006 - 05:00 PM

I'm creating a script that will let me accept/reject signups. I'm stuck on how to make a button to Accept/Reject each signup. Each signup is a row in a mysql table, and it's also displayed like that in html using tables. My question is how would I perform an action on the row the button is near. MySQL is still very new to me so I'm having a hard time figuring out if I need to focus more on the PHP side or SQL side.
Heres how its setup now: http://i10.tinypic.com/2qcngk5.png
<?PHP
  include "db.php";
  $query = "SELECT `fname`, `lname`, `email`, `phone`, `address`, `citystate`, `country`, `domain`, `username`, `password`, `rules`, `legal`, `atleast18`, `details`, `aboutus`, `ip` FROM users WHERE `status` = '1'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  echo "<table border='1'>";
  echo "<tr><th>Full Name</th><th>Last Name</th><th>Email</th><th>Phone</th><th>Address</th><th>City/State</th><th>Country</th><th>Domain</th><th>Username</th><th>Password</th><th>Rules</th><th>Legal</th><th>18?</th><th>Details</th><th>About us?</th><th>IP</th></tr>";
  while ($data = mysql_fetch_array($result)) {
    echo "<tr><td>";
    echo $data['fname'];
    echo "</td><td>";
    echo $data['lname'];
    echo "</td><td>";
    echo $data['email'];
    echo "</td><td>";
    echo $data['phone'];
    echo "</td><td>";
    echo $data['address'];
    echo "</td><td>";
    echo $data['citystate'];
    echo "</td><td>";
    echo $data['country'];
    echo "</td><td>";
    echo $data['domain'];
    echo "</td><td>";
    echo $data['username'];
    echo "</td><td>";
    echo $data['password'];
    echo "</td><td>";
    echo $data['rules'];
    echo "</td><td>";
    echo $data['legal'];
    echo "</td><td>";
    echo $data['atleast18'];
    echo "</td><td>";
    echo $data['details'];
    echo "</td><td>";
    echo $data['aboutus'];
    echo "</td><td>";
    echo $data['ip'];
    echo "</td></tr>";
  }
  echo "</table>";
  mysql_free_result($result);
  mysql_close($mlink);
?>

To obtain peace and quiet, get a Phoneless Cord.


#2 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 26 September 2006 - 06:33 PM

Well 2 things, please md5 the passwords so they won't get stolen so easily.

2nd thing. When they sign up, if you want to give the option of keeping the name/info in the database but decline their signup, then add another field to that row called "accept". 0 is no, 1 is yes.

Then on this part that echos all the information, simply put some form buttons at the bottom that tells whether or not to accept the person. YES = 1 NO = 0.

Onto your page where it gets the info, what you want to do is read this from the form. Once it reads 0 or 1, simply update that row with the answer 0 or 1 (yes or no) and there you go. Then from your site, have it display users with the field accept that equals 1. WHA LA.

#3 esahp

esahp
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationUSA

Posted 26 September 2006 - 08:38 PM

I don't understand how to tell the rows apart. I've added a new part in the table for the Accept/Reject button, and the buttons themselves, I just have no clue how to make the buttons update the row that it sits on.
<?PHP
  include "db.php";
  $query = "SELECT `fname`, `lname`, `email`, `phone`, `address`, `citystate`, `country`, `domain`, `username`, `password`, `rules`, `legal`, `atleast18`, `details`, `aboutus`, `ip` FROM users WHERE `status` = '1'";
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  echo "<table border='1'>";
  echo "<tr><th>Full Name</th><th>Last Name</th><th>Email</th><th>Phone</th><th>Address</th><th>City/State</th><th>Country</th><th>Domain</th><th>Username</th><th>Password</th><th>Rules</th><th>Legal</th><th>18?</th><th>Details</th><th>About us?</th><th>IP</th><th>A/R</th></tr>";
  while ($data = mysql_fetch_array($result)) {
    echo "<tr><td>";
    echo $data['fname'];
    echo "</td><td>";
    echo $data['lname'];
    echo "</td><td>";
    echo $data['email'];
    echo "</td><td>";
    echo $data['phone'];
    echo "</td><td>";
    echo $data['address'];
    echo "</td><td>";
    echo $data['citystate'];
    echo "</td><td>";
    echo $data['country'];
    echo "</td><td>";
    echo $data['domain'];
    echo "</td><td>";
    echo $data['username'];
    echo "</td><td>";
    echo $data['password'];
    echo "</td><td>";
    echo $data['rules'];
    echo "</td><td>";
    echo $data['legal'];
    echo "</td><td>";
    echo $data['atleast18'];
    echo "</td><td>";
    echo $data['details'];
    echo "</td><td>";
    echo $data['aboutus'];
    echo "</td><td>";
    echo $data['ip'];
    echo "</td><td>";
    echo "<form action=\"blah.php\" method=\"post\"><input type=\"submit\" value=\"A\">";
    echo "<input type=\"submit\" value=\"R\"></form>";
    echo "</td></tr>";
  }
  echo "</table>";
  mysql_free_result($result);
  mysql_close($mlink);
?>

To obtain peace and quiet, get a Phoneless Cord.


#4 livepjam

livepjam
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 26 September 2006 - 08:57 PM

please md5 the passwords so they won't get stolen so easily.


Isn't SHA1 more secure?

#5 esahp

esahp
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationUSA

Posted 27 September 2006 - 01:39 AM

bump
Please help..

To obtain peace and quiet, get a Phoneless Cord.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users