|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
php5 - Updating MySQL Through a PHP Form
Hi, I created a script that was supposed to update MySQL through a form. Here is my code:
<?php error_reporting(E_ALL); ini_set("display_errors", "on"); $con = mysql_connect("localhost","username","password"); mysql_select_db("db_name", $con); $sql = "UPDATE users SET username = '{$_POST['username']}',password = '{$_POST['password']}',userlevel = '{$_POST['userlevel']}' WHERE id = 23 LIMIT 1"; mysql_query($sql) or die (mysql_error()); ?> It doesn't work, and no error comes up. What am I doing wrong? Here is my form: <form enctype="multipart/form-data" action="adm.php" name="frm1" method="POST"> ID to edit:<br> <input type="text" name="username"><br /> New Password:<br> <input type="text" name="password"><br /> Userlevel:<br> <select id="select1" name="userlevel"> <option name="1" value="1">1</option> <option name="2" value="2">2</option> <option name="3" value="3">3</option> <option name="4" value="4">4</option> <option name="5" value="5">5</option> <input type="checkbox" id="chk1" name="userlevel" onchange="javascript:toggleSelect();" value="0" /> Banned </select> <br> <input type="submit" name="edit" value="Update"></form>[/PHP] I don't think it is a problem with the form, unless it is the button. What do you think is wrong? Thanks! |
|
#2
|
||||
|
||||
|
first of all you have the right idea but you need to tell the scriipt that your submiting the information because if you dont then it will just do nothing you need to do something like this
PHP Code:
there is also no point in having LIMIT 1 in there because you are only updating a table in your SQL your not selecting information to be shown so you have a choice now with your code you can have it all on one page or have it on seperate pages for example this will work PHP Code:
or you can have them on seperate pages what ever floats ya boat hope this helps
__________________
the best way to learn
1. check the site because it rules 2. search your functions up on php.net 3. surf the web google.com 4. lookup tutorials tutorialized.com |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > php5 - Updating MySQL Through a PHP Form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|