Jump to content

[SOLVED] help please


mjgdunne

Recommended Posts

Hi everyone,

I have a php page which displays information and images, on this page i have added a textarea so that the user can add notes, my problem is, is that the notes are not being uploaded into the database.

 

Here is the code for displaying, and the textarea:

<?php
session_start();
if($_SESSION['loggedin'] != "true") {
header("Location: main_login.html");
}
else {
?>

<html>
<head>
<title>Car Rentals & Returns</title>
<meta http-equiv="Content-Type" content="text/html" />
<link href="style2.css" rel="stylesheet" type="text/css" />

<SCRIPT LANGUAGE="JavaScript">
document.write(Date());
</SCRIPT>

</head>
<body>
<div id="wrapper3">
<img src="images/cars.jpg" width="996" height="100"></a>

<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%>
<tr>
<td align="center">
<H1>View Cases:</H1>
</td>
</table>

<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%>
<tr>
<TD ALIGN=CENTER>



<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="reff"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$pid = $_GET['pid'];
$sql = "SELECT * FROM reff WHERE `pid` = '$pid'";
$result = mysql_query($sql) or die(mysql-error());
$row = mysql_fetch_assoc($result);


echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>ID</th>";
	echo "<td>";
        echo $row['pid'];
echo "</td>";


echo "<tr><th>Make</th>";
	echo "<td>";
        echo $row['make'];
echo "</td>";


echo "<tr><th>Model</th>";
	echo "<td>";
        echo $row['model'];
echo "</td>";

echo "<tr><th>Registration</th>";
	echo "<td>";
    echo $row['registration'];
echo "</td>";

echo "<tr><th>Image</th>";
	echo "<td>";
    	echo "<img src='upload/".$row['image']."' width='250' height='250'/>";
echo "</td>";

echo "<tr><th>Image</th>";
	echo "<td>";
    	echo "<img src='upload/".$row['image2']."' width='250' height='250'/>";
echo "</td>";

echo "<tr><th>Image</th>";
	echo "<td>";
    	echo "<img src='upload/".$row['image3']."' width='250' height='250'/>";
echo "</td>";

echo "<tr><th>Image</th>";
	echo "<td>";
    	echo "<img src='upload/".$row['image4']."' width='250' height='250'/>";
echo "</td>";

echo "<tr><th>Damage Report</th>";
	echo "<td>";
    	echo "<a href='upload/".$row['report']."' target='_blank'>Click Here to view damage report</a>";
echo "</td>";



echo "<tr><th>Notes on Case</th>";
	echo "<td>";
echo '<textarea name="mynotes"></textarea>';
echo "</td>";

echo '<form action="save.php?pid='.$row['pid'].'" method="post">';



echo "<tr><th></th>";
	echo "<td>";
    	echo "<button onclick=\"window.location.href='save.php?pid=".$row['pid']."'\">Save</button>";
echo "</td>";

?>


<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=30%>
<tr>
</td>

<form method="post" action="login_success2.php">
<td align="center">
<input type="submit" value="Home"/></form>
</tr>
</table>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
<?php
}
?>[code]

Here is my code for saving the information to the database:

[code]<?php
session_start();
if($_SESSION['loggedin'] != "true") {
header("Location: main_login.html");
}
else {
?>

<html>
<head>
<title>Car Rentals & Returns</title>
<meta http-equiv="Content-Type" content="text/html" />
<link href="style2.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper3">
<img src="images/cars.jpg" width="996" height="100"></a>

<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%>
<tr>
<td align="center">
<H1>Notes Added</H1>
<form action="login_success2.php" method="post">
</td>
</table>
<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%>
<tr>
<TD ALIGN=CENTER VALIGN=TOP WIDTH=50>
</TD>
<TD ALIGN=LEFT VALIGN=TOP WIDTH=83%>
</table>

<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="reff"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$pid = $_GET['pid'];

$mynotes=$_POST['mynotes'];

mysql_select_db("test");

$sql = "UPDATE reff SET notes = '" . $_POST['mynotes'] . "'WHERE `pid` ='$pid'";
mysql_query($sql) or die(mysql_error());
echo '<br />Query was:'.$sql;
echo 'Notes are:'.$mynotes;

?>

<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%>
<tr>
<td align="center"><input type="submit" value="Home"/></td>
</tr>
</table>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
<?php
}
?>

[/code][/code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.