scottyrob
10-20-2006, 02:18 AM
Hi,
Ive just made the following but it dosent want to work... When i submit the information, the page just refreshes with the original old data. Any ideas how to fix it and improve the script?
Cheers,
Scott
update.php
<?php require("index_top.php"); require("index_left.php"); ?>
<?php
require("files/db_connect.php");
$result = @mysql_query("SELECT * FROM tbl_register WHERE reg_id = ".$_GET["reg_id"]);
while ($row = mysql_fetch_assoc($result))
{
echo "<form method='post' action='update_script.php'>";
echo "<input type='text' name='email_id' value='{$row['email_id']}';";
echo "<br><br><input type='text' name='reg_id' value='{$row['reg_id']}';";
echo "<br><br><input type='text' name='fullname' value='{$row['fullname']}';";
echo "<br><br><input type='text' name='username' value='{$row['username']}';";
echo "<br><br><input type='text' name='password' value='{$row['password']}';";
echo "<br><br><input type='text' name='status' value='{$row['status']}';";
echo "<input type='submit' name='update' value='Update' >";
echo "</form>";
}
?>
<?php require("index_right.php"); require("index_bottom.php"); ?>
update_script.php
<?php
require("files/db_connect.php");
$reg_id=$_POST['reg_id'];
$email_id=$_POST['email_id'];
$fullname=$_POST['fullname'];
$username=$_POST['username'];
$password=$_POST['password'];
$status=$_POST['status'];
$query = "UPDATE tbl_register SET email_id = '$email_id', fullname = '$fullname', username = '$username', password = '$password', status = '$status' WHERE reg_id = '$reg_id'";
mysql_query($query);
?>
Ive just made the following but it dosent want to work... When i submit the information, the page just refreshes with the original old data. Any ideas how to fix it and improve the script?
Cheers,
Scott
update.php
<?php require("index_top.php"); require("index_left.php"); ?>
<?php
require("files/db_connect.php");
$result = @mysql_query("SELECT * FROM tbl_register WHERE reg_id = ".$_GET["reg_id"]);
while ($row = mysql_fetch_assoc($result))
{
echo "<form method='post' action='update_script.php'>";
echo "<input type='text' name='email_id' value='{$row['email_id']}';";
echo "<br><br><input type='text' name='reg_id' value='{$row['reg_id']}';";
echo "<br><br><input type='text' name='fullname' value='{$row['fullname']}';";
echo "<br><br><input type='text' name='username' value='{$row['username']}';";
echo "<br><br><input type='text' name='password' value='{$row['password']}';";
echo "<br><br><input type='text' name='status' value='{$row['status']}';";
echo "<input type='submit' name='update' value='Update' >";
echo "</form>";
}
?>
<?php require("index_right.php"); require("index_bottom.php"); ?>
update_script.php
<?php
require("files/db_connect.php");
$reg_id=$_POST['reg_id'];
$email_id=$_POST['email_id'];
$fullname=$_POST['fullname'];
$username=$_POST['username'];
$password=$_POST['password'];
$status=$_POST['status'];
$query = "UPDATE tbl_register SET email_id = '$email_id', fullname = '$fullname', username = '$username', password = '$password', status = '$status' WHERE reg_id = '$reg_id'";
mysql_query($query);
?>