furqan219 Posted June 9, 2009 Report Share Posted June 9, 2009 hi this is code of form in which i have populated data from databse. <form action="update.php" method="post"><input type="text" name="userdate" value="<?= $b ?>" /> <input type="submit" name="subjoin" value="Update"></form> and update.php $c= $_POST["$b"];echo "value".$c; //its not working but it does not post a value Link to comment Share on other sites More sharing options...
smerny Posted June 9, 2009 Report Share Posted June 9, 2009 (edited) the data is stored under the name... you need to either change the name from "userdate" to "b" in the form AND change $_POST["$b"] to $_POST["b"] in update.phpor change $_POST["$b"] to $_POST["userdate"] in update.php Edited June 9, 2009 by smerny Link to comment Share on other sites More sharing options...
furqan219 Posted June 9, 2009 Author Report Share Posted June 9, 2009 I do this but when i click update button it shows blank page in result of update.php Link to comment Share on other sites More sharing options...
smerny Posted June 9, 2009 Report Share Posted June 9, 2009 then there is another problem, can you show more of the update.php page? Link to comment Share on other sites More sharing options...
furqan219 Posted June 9, 2009 Author Report Share Posted June 9, 2009 this is a code <?php$con = mysql_connect("localhost","xxx","xxx");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("onm", $con);$c= $_POST['name'];echo $c;echo "0play";/*mysql_query("UPDATE SitePInfo SET Age = '36'WHERE FirstName = 'Peter' AND LastName = 'Griffin'");*/mysql_close($con); ?> Link to comment Share on other sites More sharing options...
furqan219 Posted June 9, 2009 Author Report Share Posted June 9, 2009 <?$con = mysql_connect("localhost","xxxx","xxxx");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("onm", $con);$result = mysql_query("SELECT * FROM sitepinfoWHERE SiteId='C-SIL-4441' "); // I just get one value at this timewhile($row = mysql_fetch_array($result)) { echo "<table cellpadding=2 cellspacing=2 width=100%><tr></tr>"; echo "<tr>"; echo "<th bgcolor=#5D9BCC >SiteID</th>"; echo "<td bgcolor=#FEE9A9>" . $row['SiteId'] . "</td>"; // show value in cell $b =$row['SiteId']; // store value in $b echo "</tr>"; }echo "</table>";mysql_close($con);?><form action="update.php" method="post" name="frmmain" id="frmmain"><!-- <input name="hdnSiteID" type="text" id="hdnSiteID" value="<?php print($b);?>" />--><input type="text" name="name" value="<?= $b ?>" /> <input type="submit" name="subjoin" value="Update"></form> Link to comment Share on other sites More sharing options...
smerny Posted June 9, 2009 Report Share Posted June 9, 2009 (edited) did you change form to this then : <form action="update.php" method="post"><input type="text" name="name" value="<?= $b ?>" /><input type="submit" name="subjoin" value="Update"></form> EDIT: nvm i see you posted the form Edited June 9, 2009 by smerny Link to comment Share on other sites More sharing options...
furqan219 Posted June 9, 2009 Author Report Share Posted June 9, 2009 I am new to PHP but I really want to learn new technique.I have tried many codes but its not working.Also I have no idea how to update databse using this method. Link to comment Share on other sites More sharing options...
smerny Posted June 9, 2009 Report Share Posted June 9, 2009 (edited) <input type="text" name="name" value="<?php echo $b; ?>" />and... the update page should not be "blank" as far as i can tell :S(should at the very least see "0play" or an error msg) Edited June 9, 2009 by smerny Link to comment Share on other sites More sharing options...
furqan219 Posted June 9, 2009 Author Report Share Posted June 9, 2009 Can I send code of both pages again? Link to comment Share on other sites More sharing options...
furqan219 Posted June 9, 2009 Author Report Share Posted June 9, 2009 Now its working Friendwith this code if(!empty($_POST["name"])){$c= $_POST["name"];echo $c; //its working} Link to comment Share on other sites More sharing options...
furqan219 Posted June 9, 2009 Author Report Share Posted June 9, 2009 thank you so much, i have another big issue. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now