So far I have a drop down box that shows a list of client names from the database... but I cant figure out how to make the clients name, email and password pop up to be changed.
The admin area is made from one index and multiple includes using domain extensions, therefore clicking links reloads the same page but with a different include.
This is what I am aiming for:
1) admin needs to change clients stored data
2) admin chooses client from drop down list
3) on submission the selected clients data is shown in a form
4) the admin can edit the data in the fields
5) the admin submits this form, and the clients info is updated.
I am stuck on step 3.
Thanks for any help in advance! (I am still self teaching)
I hope that makes sense, here's the code so far:
PHP Code:
<?php
$conn = mysql_connect("localhost", "root", "");
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("report")) {
echo "Unable to select report DB: " . mysql_error();
exit;
}
$sql = ("SELECT * FROM clients ORDER BY client DESC");
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if(isset($_POST['goedit'])){
include("config.php");
$client_name = ("SELECT client FROM clients WHERE client = '$client'");
$client_email = ("SELECT email FROM clients WHERE client = '$client'");
$client_password = ("SELECT password FROM clients WHERE client = '$client'");
$result1 = mysql_query($client_name);
$result2 = mysql_query($client_email);
$result3 = mysql_query($client_password);
?>
<div class="primary">
<form action="" method="post" target="_self" id="registerform">
<div>
<p>Client creation form</p>
</div>
<div>
<label>Client Name <span class="required">*</span></label>
<?php echo('<input name="client" type="text" id="client" value="'.$result1.'" />'); ?>
</div>
<div>
<label>Primary Email Address <span class="required">*</span></label>
<?php echo('<input name="email" type="text" id="email" value="'.$result2.'" />'); ?>
</div>
<div>
<label>Primary Password <span class="required">*</span></label>
<?php echo('<input name="password" type="password" id="password" value="'.$result3.'" />'); ?>
</div>
<div>
<input type="submit" value="Update Client" class="button" name="register2" id="register2">
</div>
</form>
<a style="font-size: 25px;" href="?d=1">Cancel and return</a>
</div>
<?php
;}
?>
<html>
<a style="font-size: 25px;" href="?d=1">Cancel and return</a><br /><br />
<section id="register" class="clearfix">
<div class="primary">
<form action="" method="post" target="_self" id="registerform">
<div>
<p>Please select the client you wish to edit:</p>
</div>
<div>
<label>Client Name<span class="required">*</span></label>
<?php
echo("<select name='client' id='client'>");
while ($row = mysql_fetch_assoc($result)) {
echo('<option>'.$row["client"].'</option>');
$client = $row["client"];
}
echo("</select>");
?>
</div>
<div>
<input type="submit" value="Edit Client" class="button" name="goedit" id="goedit">
</div>
</form>
<br />
<a style="font-size: 25px;" href="?d=1">Cancel and return</a>
</div>
</section>
</html>