I have following tables and following is the query I have used all possible checks to solve this issue. The problem is the insert works with phpMyAdmin but not with PHP. I tried everything but still have the same problem.
Here is my table code:
CREATE TABLE IF NOT EXISTS `cle` (
`id` int(40) NOT NULL AUTO_INCREMENT,
`title` varchar(444) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Article',
`content` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`url` varchar(222) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`status` int(11) DEFAULT '0',
`alt` varchar(400) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `url` (`url`,`status`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Here is the insert code:
INSERT INTO cle (content,url,alt) VALUES (' <br> <span name=KonaFilter style=\"width:100%;\"><center><font size=\"4\"><b>Rate? Part 1</b> by<b> </b></font></center></span> <span> <br> <center> <br><td><img src=\"http://a1.abc.com/a/spacer.gif\" height=\"0\" width=\"1\"></td></tr> <tr><td>Article Posted: 04/04/2005</td></tr> </table> </td> </tr> </table> <table cellspacing=\"0\" cellpadding=\"1\" width=\"100%\" border=0> <tr> <td><h1 style=\"color:02679D; font-size:16\"><b><span name=KonaFilter>Howe? Part 1</span></b></h1></td> <td align=\"right\"> <table border=0 cellpadding=4> <tr> <td valign=\"top\"> <img name=\"btn36\" src=\"http://a4.abc.com/a/js_feed_article.gif\" width=48 height=38 onclick=\"ClipBoard(input36);\" onmouseover=\"this.style.cursor = \'hand\';\"> <input type=\"hidden\" name=\"input36\" value=\'</td> <td valign=\"top\"> <img src=\"http://a4.abc.com/a/email_me.gif\" width=38 height=33 border=0> </td> </tr> </table> </td> </tr> <tr> <td colspan=2> </td> </tr> <tr><td><br> <br></td></tr> <tr> <td valign=\"bottom\" colspan=2> <form name=\"formx\" action=\"/article_detail.cfm?articleid=36\" method=\"post\"> <input type=\"hidden\" name=\"flagged\" value=1> <input type=\"image\" src=\"http://a1.abc.com/a/categorize.gif\" alt=\"Is gory?\" onclick=\"flag();\"> </form> </td></tr> </tr> <tr><td colspan=2><img src=\"http://a1.abc.com/a/spacer.gif\" height=\"5\" width=\"1\"></td></tr> <tr><td colspan=2> <div align=left style=\"width:370; height:315;\">s we’ll sues. <br> Question 1:? Do on such as “read more here” or? <br> What bsite. “Read More Here” us ASP vendors, rates, why itrates. <br> <p><br<!-- --> <table cellspacing=1 cellpadding=\"1\" border=0 width=\"130\" bgcolor=\"5A5A5A\"> <tr> <td valign=\"middle\" align=\"right\" height=\"10\" style=\"background-repeat:no-repeat;\" bgcolor=\"ffffff\" background=\"http://a15.abc.com/a/catbox.gif\"> <font face=\"arial\" style=\'font-size:12\'><b><font style=\'font-family:verdana; font-size:9\'>Rate This Article</font> <img onclick=\'closeWindow();\' src=\'/a/close.gif\'> </b></font></td> </tr> <tr><td bgcolor=\"dddcdd\"> <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"> <tr> <td align=\"center\"> <table border=0> <form name=\"form2\" action=\"\" method=\"post\"> <tr><td colspan=5><input type=\"text\" name=\"xDesc\" value=\"\" style=\"border:0 px; font-size:10;background-color:dddcdd\" contenteditable=\"false\"></td> </form> <tr> <td width=\"20%\"> </td> <td width=\"20%\"> <form name=\"rateform2\" action=\"/feedback.cfm/36?articleid=36&title=2C1\" method=\"post\"> <input type=\"hidden\" name=\"rating\" value=2> <img src=\"http://a2.abc.com/a/empty_star.gif\" name=\"imagetwo\" alt=\"Minimal useful information.\" style=\"border:0px\" onclick=\"rate(2);\" onmouseover=\"starDesc(2);\" onmouseout=\"starDesc(0);emptyStar(2);\"> </form> </td> <td width=\"20%\"> <form name=\"rateform3\" action=\"/f.cfm/36?articleid=36C1\" method=\"post\"> <input type=\"hidden\" name=\"rating\" value=3> <img src=\"http://a3.abc.c.gif\" name=\"imagethree\" alt=\"Decent and informative.\" style=\"border:0px\" onclick=\"rate(3);\" onmouseover=\"starDesc(3);\" onmouseout=\"starDesc(0);emptyStar(3);\"> </form> </td> <td width=\"20%\"> <form name=\"rateform4\" action=\"/feedback.cfm/36?articleid=36&title=C1\" method=\"post\"> <input type=\"hidden\" name=\"rating\" value=4> <img src=\"http://a4.abc.com/a/emptyr.gif\" name=\"imagefour\" alt=\"Gre.\" style=\"border:0px\" onclick=\"rate(4);\" onmouseover=\"starDesc(4);\" onmouseout=\"starDesc(0);emptyStar(4);\"> </form> </td> <td width=\"20%\"> <form name=\"rateform5\" action=\"/fem/36?articleid=36&title=C1\" method=\"post\"> <input type=\"hidden\" name=\"rating\" value=5> <img src=\"http://a5.abc.com/a/empty_star.gif\" name=\"imagefive\" alt=\"A \'Must Read\'.\" style=\"border:0px\" onclick=\"rate(5);\" onmouseover=\"starDesc(5);\" onmouseout=\"starDesc(0);emptyStar(5);\"> </form> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr><td bgcolor=\"5A5A5A\"><img src=\"http://a1.aer.gif\" height=\"8\" width=\"100%\"></td></tr> </table> </div> <script type=\"text/javascript\"> //Enter \"frombottom\" or \"fromtop\" var verticalpos=\"frombottom\" function JSFX_FloatTopDiv() { var tmpcookie = new Date(); chkcookie = (tmpcookie.getTime() + \'\'); document.cookie = \"chkcookie=\" + chkcookie + \"; path=/\"; if (document.cookie.indexOf(chkcookie,0) < 0) { divStayTopLeft.style.left=-1000; } else { starDesc(0); var startX = 0, startY = 100; var ns = (navigator.appName.indexOf(\"Netscape\") != -1); var d = document; function ml(id) { var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id]; if(d.layers)el.style=el; el.sP=function(x,y){this.style.left=x;this.style.top=y;}; el.x = startX; if (verticalpos==\"fromtop\") el.y = startY; else{ el.y = ns ? page
<p> </td> </tr> <tr><td align=\"center\" > <p> <p> <font size=3 color=990000>Doe? Have a Comment? POST IT!</font><p> <table cellspacing=1 cellpadding=\"4\" border=0 width=\"100%\" bgcolor=\"4D4D4D\" align=\"center\"> <tr> <td align=\"right\" height=\"23\" style=\"background-repeat:no-repeat;\" bgcolor=\"ffffff\" background=\"\"> <font face=\"arial\" style=\'font-size:12\'><b>Re</b></font> </td> </tr> <tr><td bgcolor=\"dddddd\"> <form action=\"/post_.cfm\" method=\"post\"> <table width=\"100%\" cellpadding=3 border=0 cellspacing=1> </table> <table width=\"100%\" cellpadding=5 border=0> <tr><td colspan=2><font size=2><strong>Sue.</strong></font></td></tr> <tr> <td colspan=2 align=\"center\">Make this comment <input type=radio selected name=PublicPrivate value=\"Public\" label=\"Public\"> <label for=\"Public\">Public</label> or <input type=radio name=PublicPrivate value=\"Private\" label=\"Private\"> <label for=\"Private\">Private</label> to th:</td> </tr> <tr> <td align=\"right\">Name:</td> <td> <input type=\"text\" name=\"name\" value=\"\" size=50> </td> </tr> <tr> <td align=\"right\" valign=\"top\">Email:</td> <td><input type=\"text\" name=\"Emss\" value=\"\" size=50><br> <font size=1 color=\"ff0000\">*Youy.</font></td> </tr> <tr> <td align=\"right\" valign=\"top\">Comments:</td> <td><font size=1 color=\"ff0000\">*Yongly.</font><br> <textarea cols=45 rows=10 name=\"Comments\"></textarea></td> </tr> <tr> <td> </td> <td><img src=\"http://a6.abc.com/f.jpg\"></td> </tr> <tr> <td align=\"right\" valign=\"top\">Pge:</td> <td align=\"left\"><input type=\"text\" maxlength=6 name=\"ImageCode\" value=\"\" size=10></td> </tr> <tr> <td colspan=2 align=\"center\"> <input type=\"hidden\" name=\"ArticleID\" value=\"36\"> <input type=\"hidden\" name=\"x\" value=\"gwSIMR\"> <input type=\"hidden\" name=\"Author
ID\" value=\"\"> <input type=\"hidden\" name=\"ReturnTo\" value=\"/article_detail.cfm?articleid=36\"> <input type=\"Submit\" value=\"Sut\" name=\"PostComment\"> </td> </tr> </table> </form> </td> </tr> <tr><td bgcolor=\"4D4D4D\"><img src=\"http://a1.abc.com/er.gif\" height=\"8\" width=\"100%\"></td></tr> </table> </td></tr> </table> </span> <br>','http://www.a.com/article_detail.cfm?articleid=36','-')
Here is a sqlfiddle.
Where am I making a mistake?
You'll need to escape things twice if you throw them in literal from PHP to MySQL. The first backslash will be interpreted by PHP, NOT by MySQL.
If you have a function called as follows (for example):
function_called("this\' quote");
The function will actually receive "this' quote", not the backslashed version.
To go around this, two solutions:
Rely on parametrization of queries provided by PDO or MySQLi (safer as well in the long run)
Double-escape stuff. This\' quote then becomes This\\\' quote. On first pass, \ is interpreted as \, \' turns into '. On second pass (MySQL), what remains is \'.
i think your insert query in wrong
you can use name=\"KonaFilter\" instead of name=KonaFilter
i think problem is at this line -
"s we’ll sues. Question 1:?"
try to replace this line to
"s we\’ll sues. Question 1:?"
Related
just trying to make a little calculator for myself in php and i wonder if its possible to make the answer instant update after i type in the values?
Thank you.
<?php
if (isset($_POST['valuea'])) $valuea = $_POST['valuea'];
if (isset($_POST['valueb'])) $valueb = $_POST['valueb'];
if (isset($_POST['check1'])) {
$answer = (($valuea * $valueb) * 10)*2;
} else {
$answer = ($valuea * $valueb) * 10;
}
echo <<<_END
<form method='post' action=''>
<table border='0' width='500px' cellpadding='3' cellspacing='1' class="table">
<tr class="calcrow">
<td>Lenght:</td>
<td align="center"><input type='text' name='valuea' value="$valuea"/></td>
</tr>
<tr class="calcrow2">
<td>Width:</td>
<td align="center"><input type='text' name='valueb' value="$valueb"/></td>
</tr>
<tr class="calcrow2">
<td>2x test</td>
<td align="center"><input type="checkbox" name="check1"></td>
</tr>
<tr class="submit"><td colspan="2"><input type='submit' value='Calculate'/></td></tr>
_END;
?>
<tr class="calcrow">
<td><i>Answer</td>
<td align="center"><input type="text" value="<?php echo round($answer)?>"></td></i>
</tr>
</table>
</form>
You are looking for a thing called Jquery.
Which can fetch current Values of your form inputs or any other elements from your webpage. Then you can then send that data to your php file where you can perform the calculation and return the result which can again be displayed wherever you want .
All of this happens in real time.
This is the way you could do it if you wanted to do it in php
Else you could always go for plain JavaScript or a mixture of jquery + javascript, to avoid using php and ajax.
Form:
<table width="100%" cellpadding="4" cellspacing="0" id="px">
<thead>
<tr class="tab_head">
<td width="25px" style="text-align:center; color:#FFFFFF; font-size:11px;">#</td>
<td class="form_label" style="color:#FFFFFF; font-size:11px;">First Name</td>
<td class="form_label" style="color:#FFFFFF; font-size:11px;">Last Name</td>
<td class="form_label" style="color:#FFFFFF; font-size:11px;">Wgt</td>
<td class="form_label" style="color:#FFFFFF; font-size:11px;">Address</td>
<td class="form_label" style="color:#FFFFFF; font-size:11px;">Phone</td>
<td class="form_label" style="color:#FFFFFF; font-size:11px;">Email</td>
<td></td>
</tr>
</thead>
<tbody id="tbl1">
<tr id="pass">
<td style="vertical-align:middle; text-align:center"><input type="text" name="pass_num[]" readonly="readonly" value="1" class="pass" style="font:Verdana; font-size:11px; border:none; background-color:transparent; width:25px; text-align:center; vertical-align:middle;" tabindex="-1"></td>
<td><input type="text" id="cfn1" name="cust_fname[]" class="form_g" /></td>
<td><input type="text" id="cln1" name="cust_lname[]" class="form_g" /></td>
<td><input type="text" name="cust_kg[]" class="form_a" /></td>
<td><input type="text" name="cust_addr[]" class="form_c" /></td>
<td><input type="text" name="cust_phone[]" class="form_g" /></td>
<td><input type="text" name="cust_email[]" class="form_b" /></td>
<td style="vertical-align:middle"><a class="removePax"><img src="images/remove_pax.png" /></a></td></tr>
</tbody>
</table>
Table Columns:
cust_id
cust_fname
cust_lname
cust_kg
cust_addr
cust_phone
cust_email
There is a snippet of JQuery that essentially clones the above table as required to allow the user to add another passenger etc. On submittinh, the data is posted to the next page fine, and I've tested numerous times that the data is coming through in Arrays (eg. $_POST[cust_fname] etc.).
The problem I'm having now is turning these into sets that I can insert into the table.
I tried a foreach loop and iterating but so far, I'm failing to come up with a solution. I have tried sorting the data into per passenger, but so far keeps clumping the data together.
JSFiddle
In your php code, you have to iterate with one for loop all the arrays in the same time and print them. Example :
cust_fname = $_POST["cust_fname"];
cust_lname = $_POST["cust_lname"];
for($i = 0; $i < count($cust_fname); $i++)
{
echo "Complete name : ".$cust_fname[$i]." ".$cust_lname[$i];
echo "<br/>";
}
I just put an example for two fields, you can do the rest :)
EDIT : I saw that you want to show them in a table, so you can change the code i gave you to :
cust_fname = $_POST["cust_fname"];
cust_lname = $_POST["cust_lname"];
echo "<table><tr><th>First name</th><th>Last Name</th></tr><tbody>";
for($i = 0; $i < count($cust_fname); $i++)
{
echo "<tr>";
echo "<td>".$cust_fname[$i]."</td><td> ".$cust_lname[$i]."</td>";
echo "</tr>";
}
echo "</tbody></table">;
I'm trying to create users and save them to my database. I have this login formula with css and html and the code to put it into my db:
function registerUser()
{
echo "
<form method='get' action=''>
<div style=\"text-align: center;\"><input class=\"button\" style=\"z-index:1;\" type=\"submit\" name=\"reset\" value=\"Neues Spiel\">
Zur Highscore
</form>
<form style=\"border:5; border-color:blue; \" align=\"center\" action=\"\" method=\"post\">
<table style='background-color:#696969' border='5' align='center'>
<tr>
<th>Dein Username:</th>
</tr>
<tr>
<td><input type=\"text\" size=\"24\" maxlength=\"50\"
name=\"username\"></td>
</tr>
<tr>
<th>Dein Passwort:</th>
</tr>
<tr>
<td><input type=\"password\" size=\"24\" maxlength=\"50\"
name=\"password\"></td>
</tr>
<tr>
<th>Passwort Wiederholen:</th>
</tr>
<tr>
<td><input type=\"password\" size=\"24\" maxlength=\"50\"
name=\"password2\"></td>
</tr>
<tr><td><input style=\"margin-left:49;\" align=\"center\" type=\"submit\" value=\"Abschicken\" name=\"saveUser\"></tr></td>
</table>
</form>
";
}
and my saveUser() function:
function saveUser($username, $password, $passwordCheck)
{
$this->db->exec("INSERT INTO users (username, password) VALUES ({$username}, {$password})");
}
And I got this in my other document to get access:
if(isset($_GET['saveUser'])){
$user->saveUser($_GET['username'],$_GET['password'],$_GET['password2']);
}
It does not work.
Modify your code and use this:
$this->db->exec("INSERT INTO users (username, password) VALUES ('{$username}', '{$password}')");
And also one thing you forgot you need to validate your data to avoid sql injections, never ever trust an input coming from the user of any type.
hello guys i have a problem with this code
when id add a comment and comment insert in database
and when i make refresh on the same page i get this warning :
One of the fields are still empty,
i think the problem in the first code
<?php
if ($_POST['add'] and $_POST['add']=='comm'){
$comm_name =strip_tags($_POST['comm_name']);
$comm_country =strip_tags(mysql_real_escape_string($_POST['comm_country']));
$c =strip_tags(mysql_real_escape_string($_POST['comm']));
$comm_thread =strip_tags(mysql_real_escape_string($_POST['comm_thread']));
$status =$_POST['status'];
$getidtopic=$_GET['id_topic'];
$post_code=$_POST['post_code'];
if ($comm_name=='' or $comm_country=='' or $c=='' or $post_code=='' ){
echo "<script>alert(\"One of the fields are still empty
\");</script>";
}else if ($_POST['post_code']==$_SESSION['code']) {
$insertcomm=mysql_query("insert into comments values('','$comm_name','$comm_country','$comm','$comm_thread','$status') ")or die (mysql_error);
echo "<script>alert(\"your comment has been adding\");</script>";
}
}
?>
and this is the comment's form
<form action='' method='post' >
<table class='rightcol' width='100%' cellpadding='0' cellspacing='5'>
<tr>
<td colspan='3' id='addcomm'>add comm</td>
</tr>
<tr>
<td width='15%' ><div id='title_comm' value=''>name : </div></td>
<td ><input type='text' name='comm_name' value='<?if (!$insertcomm){
echo $comm_name;
}?>'/></td>
</tr>
<tr>
<td width='15%' ><div id='title_comm'>country </div></td>
<td ><input type='text' name='comm_country'
value='<?if (!$insertcomm){echo $comm_country;}?>'/>
</td>
</tr>
<tr>
<td valign='top' width='15%'><div id='title_comm'>comment : </div></td>
<td width='50%'>
<textarea cols='55' rows='12' name='comm'>
<?if (!$insertcomm){echo $c;}?>
</textarea></td>
<td valign='top' ><div id='note_comm'>
your comment will not insert if you try to use some thing bad
</div></td>
</tr>
<tr>
<td width='15%' ><div id='title_comm'><span style='color:red'>code : <br/>write these codes </span></div></td>
<td ><input type='text' name='post_code'/></td>
</tr>
<tr>
<td ><div id='code'>
<?php
$text=rand(400,80000);
echo $_SESSION['code']=$text;
?>
</div></td>
</tr>
<td colspan='4' ><input type='submit' name='addcomm' id='add' value='add comm'/></td>
</table>
<input type='hidden' name='comm_thread' value='<?php echo $getidtopic;?>' />
<input type='hidden' name='add' value='comm'/>
<input type='hidden' name='status' value='2'/>
</form>
that is because, when you refresh the page, the $_POST fields are reset, and the fields get empty, so when the page executes its PHP line if ($comm_name=='' or $comm_country=='' or $c=='' or $post_code=='' or $post_code=='' ){ it will find them to be empty.
You need to show us the table definition to better figure out what the issue is exactly. My guess is that your SQL statement is not properly prepared.
I am working on a web based contact list for a friend. I have the html portion all done and working on the PHP scripts and such. I have the main page as a table in a while loop enclosed in form tags. I need two things to happen but not sure how to get this accomplished.
First, each row has to have two submit buttons, which one goes to edit and the other to details, and carries over the values in the global $_POST.
Second, the list will be about 300 rows, so i am using a while loop to create the table.
I have the form working and passing the data but it is always passing the last row of the table. Here is my main page with the table:
<?php
if
(!isset ($_SESSION['username']))
{
session_start();
}
?>
<html>
<head>
<title>Client Contact List</title>
</head>
<?php
$user1 = implode(',',$_SESSION);
//DB information
require_once('/includes/db.php');
//Declaring edit and details
$edit = "<INPUT type='image' src='/addressbook/images/edit.png' onclick='\addressbook\edit.php'>";
$details = "<INPUT type='image' src='/addressbook/images/contact.gif' name='details' onclick='f1.action='\addressbook\contact_details.php'>";
//Table declarations and such
mysql_connect("$host", "$username", "$password") or die(mysql_error());
mysql_select_db("$db_name")or die("cannot select DB");
$result = mysql_query("SELECT * FROM contacts") or die(mysql_error());
$num=mysql_numrows($result);
$user1 = implode(',',$_SESSION);
$userresults = "SELECT first FROM i_user where userid IN $user1";
$user = mysql_query($userresults);
// print_r ($_SESSION);
// print_r ($_POST);
?>
<body style="background-image: url('Images/background_login.jpg');">
<br><br><br><br><br><br>
<table>
<br><br>
<tr><td width="500">Welcome Back, <?php echo $user; ?></td><td width="500"></td><td width="300"><form name="search" method="post" id="searchform" action="<?php echo $_SERVER['PHP_SELF'];?>"><label for="searchtext">Search: </label><input type="text" name="name" /> <input type="submit" name="submit" value="Search" /></form>
</td></tr>
</table>
<br>
<form name="f1" method="post" action="/addressbook/edit.php">
<table border="1">
<tr>
<?php
echo "<table border='1'>";
echo "<tr>
<th>First</th>
<th>Last</th>
<th>Company</th>
<th>Primary Email</th>
<th>Secondary Email</th>
<th>Primary Phone</th>
<th>Second Phone</th>
<th>Action</th>
</tr>";
$i=0;
while ($i<$num) {
$id = mysql_result($result,$i,"id");
$first = mysql_result($result, $i, "first");
$last = mysql_result($result,$i, "last");
$company = mysql_result($result, $i, "company");
$email1 = mysql_result($result,$i, "email1");
$email2 = mysql_result($result,$i, "email2");
$phone = mysql_result($result,$i, "phone");
$mobile = mysql_result($result,$i, "mobile");
// Print out the contents of each row into a table
echo "<tr><td width = '100'><center><input type='hidden' value='$first' name='first'>";
echo $first;
echo "</center></td><td width = '100'><center><input type='hidden' value='$last' name='last'>";
echo $last;
echo "</center></td><td width = '100'><center><input type='hidden' value='$company' name='company'>";
echo $company;
echo "</center></td><td width = '100'><center><input type='hidden' value='$email1' name='email1'>";
echo $email1;
echo "</center></td><td width = '100'><center><input type='hidden' value='$email2' name='email2'>";
echo $email2;
echo "</center></td><td width = '100'><center><input type='hidden' value='$phone' name='phone'>";
echo $phone;
echo "</center></td><td width = '100'><center><input type='hidden' value='$mobile name='mobile'>";
echo $mobile;
echo "</center></td><td width = '100'><center>";
echo $edit;
echo "    ";
echo $details;
echo "</td></center></tr>";
echo "<input type='hidden' value='$id name='id'></td>";
$i++;
}
?>
</tr>
</table>
</form>
</body>
</html>
This get directed to either the details or edit page. Below is the edit page....
<?php
if
(!isset ($_SESSION['username']))
{
session_start();
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Contact Information</title>
</head>
<?php
//DB information
require_once('/includes/db.php');
mysql_connect("$host", "$username", "$password") or die(mysql_error());
mysql_select_db("$db_name")or die("cannot select DB");
$id = $_POST['id'];
$first = $_POST['first'];
$last = $_POST['last'];
$company = $_POST['company'];
$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$phone = $_POST['phone'];
$mobile = $_POST['mobile'];
//pulling the record id from the main login page.
$first=$_POST['first'];
$query="SELECT * FROM contacts where last=$last";
$result=mysql_query($query);
print_r($_POST);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<body style="background-image: url('Images/background_login.jpg');">
<br><br><br><br><br>
<!-- First Table with the back and search option but disabled for now -->
<table>
<br>
<tr>
<td width="500">
<input type='button' value='Back' onClick='history.go(-1)'>
</td>
<td width="500"></td>
<td width="300">
<!-- <form name="search" method="post" id="searchform" action="<?php echo $_SERVER['PHP_SELF'];?>">
<label for="searchtext">Search: </label>
<input type="text" name="name" /> <input type="submit" name="submit" value="Search" />
</form> -->
</td>
</tr>
</table>
<br><br>
<center>
<!-- Second Table with form data pulled out for Identify -->
<table>
<tr>
<th>
<table>
<tr>
<td bgcolor="silver" colspan="4"><center>Identify</center></td>
</tr>
<tr>
<td width="100"><center><b>Title</b></center></td>
<td width="100"></td>
<td width="150"><center><b>Company Name</b></center></td>
</tr>
<tr>
<td width="100"><input value="Title"></td>
<td width="100"></td>
<td width="100"><? echo $company ?></td>
</tr>
<tr><td colspan="4"></td></tr>
<tr>
<td width="100"><center><b>First Name</b></center></td>
<td width="100"></td>
<td width="100"><center><b>Last Name</b></center></td>
</tr>
<tr>
<td width="100"><input value="Test"></td>
<td width="100"></td>
<td width="100"><input value="Test"></td>
</tr>
</table>
</th> <!-- Space between the contact info and Indenty -->
<td width="100">
</td>
<th>
<td> <!-- Third Table with form data pulled out -->
<table>
<tr>
<td bgcolor="silver" colspan="4"><center>Contact Information</center></td>
</tr>
<tr>
<td width="100"><center><b>Office Phone</b></center></td>
<td width="100"></td>
<td width="150"><center><b>Mobile Name</b></center></td>
</tr>
<tr>
<td width="100"><input value="Test"></td>
<td width="100"></td>
<td width="100"><input value="Test"></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
<tr>
<td width="100"><b>Primary Email</b></td>
<td width="100"></td>
<td width="150"><b>Secondary Email</b></td>
</tr>
<tr>
<td width="100"><input value="Test"></td>
<td width="100"></td>
<td width="100"><input value="Test"></td>
</tr>
</table>
</td>
</th>
<tr height="100"> <td colspan="9"></td> </tr>
<th class="style2">
<table>
<tr width="400"></tr>
<tr>
<td bgcolor="silver" colspan="4"><center>Applications Used</center></td>
</tr>
<tr>
<td width="100"></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
<tr>
<td width="100"></td>
</tr>
<tr>
<td width="100"></td>
<td width="100"></td>
<td width="100"></td>
<td width="100"></td>
</tr>
</table>
</th>
<td width="200"></td>
<td>
<th class="style2">
<table>
<tr>
<td bgcolor="silver" colspan="4"><center>Internal Information</center></td>
</tr>
<tr>
<td width="100"><center><b>Account Mgr</b></center></td>
<td width="100"></td>
<td width="150"><center><b>Client Relations</b></center></td>
</tr>
<tr>
<td width="100"><input value="Test"></td>
<td width="100"></td>
<td width="100"><input value="Test"></td>
</tr>
<tr><td colspan="4"></td></tr>
<tr>
<td width="200"><center><b>Acct Development</b></center></td>
<td width="100"></td>
<td width="100"><center><b>Project Mgr</b></center></td>
</tr>
<tr>
<td width="100"><input value="Test"></td>
<td width="100"></td>
<td width="100"><input value="Test"></td>
</tr>
</table>
</th>
</td>
</table>
</center>
</body>
</html>
Any thoughts on how to get this done?
Put the form tag inside the loop. And place the submit button inside the form tag.
It sounds like you need a lot of form, instead of a form with a lot of field.
Yet another suggestion.. jqgrid may be a good thing to use here. look it up if you got a chance.
The problem is you are creating a ton of elements that have the same name... Every row has a input by the name of email1, email2, phone, mobile, etc.
when you submit the form it just takes the value of the last html element with the given name. So it will alwyas give you the last row.
What you can do is only have 1 hidden input for each attribute. Then when you select a row, you can set the values for the hidden inputs using javascript.
HOWEVER, to make it more simple... You are already storing all of the users data in a database so you don't need to pass it all to the next page. Just pass the id to the next page, then when you get to the next page perform a select query to get all of that user's data.
This way you can have 1 hidden input for the id. When the user selects the row they want to edit use Javascript to set the value of that input.
Each button should look something like this:
echo "<input type=\"button\" onclick=\"document.form.id=$id\">";
The input should look something like this:
echo "<input type=\"hidden\" name=\"id\"/>";
Then on the edit page use :
$id = $_POST['id'];
$query = "SELECT id, first, last, company, email1, email2, phone, mobile
FROM contacts WHERE ID=$id"
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$id = $row['id'];
$first = $row['first'];
etc...