I'm writing a work order system using PHP and MySQL and I'm stuck on two things-transferring data and updating the data.
Here is my code:
i'm using checklogin.php to do most of everything so it's most likely something I'm missing here.
checklogin.php
Now for my second problem.
update.php
Any help would be GREATLY appreciated.
Here is my code:
i'm using checklogin.php to do most of everything so it's most likely something I'm missing here.
checklogin.php
Code:
<?php
$host="example.com"; // Host name
$username="gancsosa"; // Mysql username
$password="******"; // Mysql password
$db_name="gancsosa_members"; // Database name
$tbl_name="logon"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db($db_name);
// username and password sent from form
$Username=$_POST['Username'];
$Password=$_POST['Password'];
// To protect MySQL injection (more detail about MySQL injection)
$Username = stripslashes($Username);
$Password = stripslashes($Password);
$Username = mysql_real_escape_string($Username);
$Password = mysql_real_escape_string($Password);
$sql="SELECT * FROM $tbl_name WHERE username='$Username' and password='$Password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("Username");
session_register("Password");
mysql_select_db(gancsosa_crystalworks);
echo "\n";
$link = mysql_connect('example.com', 'gancsosa', '*****');
mysql_select_db("gancsosa_crystalworks") or die(mysql_error());
$data = mysql_query("SELECT * FROM inprogress")
or die(mysql_error());
//Transfer data
Print "<br><br>";
Print "Inprogress<br><br>";
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
@mysql_query( "UPDATE INTO complete SELECT FROM inprogress WHERE Status='1' ");
Print "<th>ID: ".$info['ID'] . "</th> ";
Print "<th>Time: " .$info['Time'] . "</th>";
Print "<th>Name: ".$info['Client'] . " </th>";
Print "<th>Number: " .$info['Number'] . "</th>";
Print "<th>Address: " .$info['Address'] . "</th>";
Print "<th>Issue: " .$info['Issue'] . "</th>";
Print "<th>Notes: " . $info['Notes'] . "</th>";
Print "<th>Status: " .$info['Status'] . "</th>";
Print "<th>Charge: $" .$info['Charge'] . "</th>";
Print '<th><a href="http://www.1fixcomputermedic.com/update.php" target="_blank">Edit?</a><th>';
Print "<br><br>";
}
Print "</table>";
Print "<br>";
Print "<br>";
Print "<br><br><br>Complete<br><br>";
$data = mysql_query("SELECT * FROM complete")
or die(mysql_error());
Print "<br><br>";
Print "<table border cellpadding=6>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>ID:</th> <td>".$info['ID'] . "</td> ";
Print "<th>Time:</th> <td>" .$info['Time'] . "</td>";
Print "<th>Name:</th> <td>".$info['Client'] . " </td>";
Print "<th>Number:</th> <td>" .$info['Number'] . "</td>";
Print "<th>Address:</th> <td>" .$info['Address'] . "</td>";
Print "<th>Issue:</th> <td>" .$info['Issue'] . "</td>";
Print "<th>Notes:</th><td>" . $info['Notes'] . "</td>";
Print "<th>Notes:</th> <td>" .$info['Notes2'] . "</td>";
Print "<th>Status:</th> <td>" .$info['Status'] . "</td>";
Print "<th>Charge:</th> <td>$" .$info['Charge'] . "</td></tr>";
}
Print "</table>";
}
else {
echo "Wrong Username or Password\r\n";
echo "Please try again....<br><br>";
echo '<a href="http://www.1fixcomputermedic.com/login.php">CLICK</a>';
}
?>
update.php
Code:
<html>
<?
$ID=$_GET['ID'];
$username="gancsosa";
$password="*****";
$database="gancsosa_crystalworks";
mysql_connect("example.com",$username,$password);
@mysql_select_db($database);
$query=" SELECT * FROM inprogress WHERE ID='$ID";
$result=mysql_query($query);
mysql_close();
//Print output
$Client=mysql_result($result,"Client");
$Number=mysql_result($result,"Number");
$Address=mysql_result($result,"Address");
$Issue=mysql_result($result,"Issue");
$Notes=mysql_result($result,"Notes");
$Status=mysql_result($result,"Status");
$Charge=mysql_result($result,"Charge");
?>
<form action="updated.php" method="post">
<input type="hidden" name="ud_ID" value="<? echo $ID; ?>">
Client: <input type="varchar(56)" name="ud_Client" value="<? echo $Client; ?>"><br>
Address: <input type="text" name="ud_Address" value="<? echo $Address; ?>"><br>
Number: <input type="bigint(20)" name="ud_Number" value="<? echo $Number; ?>"><br>
Issue: <input type="longtext" name="ud_Issue" value="<? echo $Issue; ?>"><br>
Notes: <input type="longtext" name="ud_Notes" value="<? echo $Notes; ?>"><br>
Status: <input type="tinyint(1)" name="ud_Status" value="<? echo $Status; ?>"><br>
<input type="Submit" value="Update">
</form>
<?
//Update
$ud_Address=$_POST['ud_Address'];
$ud_Number=$_POST['ud_Number'];
$ud_Issue=$_POST['ud_Issue'];
$ud_Notes=$_POST['ud_Notes'];
$ud_Status=$_POST['ud_Status'];
$username="gancsosa";
$password="*****";
$database="gancsosa_crystalworks";
mysql_connect("example.com",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="UPDATE inprogress SET Address='$ud_Address', Number='$ud_Number', Issue='$ud_Issue', Notes='$ud_Notes2', Status='$ud_Status' WHERE ID='ud_ID' ";
mysql_query($query);
mysql_close();
?>
</html>
Comment