andyjcurtis Posted July 18, 2010 Share Posted July 18, 2010 HI I'm kinda new to PHP Mysql, so I Dont really know how to define my problem properly to search for a solution. So far I have only found Solutions to update and Insert, I am having some problems sending data across to a different page. I am looking for a solution without using a onscreen button to submit tha data. I would like to send the data across via Href ( either javascript Submit or just a Href link) I have included both in my code. So if you could please point me in the right direction and inform me where i am going wrong that would br great. thank you In advance btw. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// FirstPageCode.php <form name="MyTable" method="POST"> <script type="text/javascript"> function submitMe() { document.MyTable.action="http://localhost/CI/Buy.php?ID=<?=$ID?>"; //document.MyTable.target="targetName"; document.MyTable.value="Send"; document.MyTable.submit(); return; } //$PostID = $_POST["PostID"]; mysql_connect('localhost', 'root', 'spe11gard'); @mysql_select_db(CI) or die( "Unable to select database"); $QueryQ="SELECT * FROM MyTable where ID"; //$QueryQ="SELECT * FROM MyTable where ID LIKE '%$PostID%'"; $ResultR=mysql_query($QueryQ);//30 $onN=mysql_numrows($ResultR); mysql_close(); echo "<b><center>on Smiths</center></b><br><br>"; ?> <table class="striped"> <tr class="header"> <td> Name </td> <td>zero </td> <td>one </td> <td>two </td> <td>three </td> <td>four </td> </tr> <?php //50 $i=0; while ($row = mysql_fetch_array($ResultR)) { $ID=$row['ID']; $zero=$row['zero']; $one=$row['one'];//60 $two=$row['two']; $three=$row['three']; $four=$row['four']; echo "<tr>"; echo "<td>$ID </td>"; echo "<td>$zero </td>"; echo "<td>$one </td>"; echo "<td>$two </td>"; echo "<td>$three </td>"; echo "<td>$four GP </td>"; echo '<td> <a href="http://localhost/CI/Buy.php?ID=<?=$ID?>"> <i>Buy</i></a> </td>'; echo '<td> <a href=javascript:this.submitMe();><i>Buy</i></a> </td>'; echo "</tr>"; $i++; } ?> </table> </form> /////////////////////////////////////////////////////////////////////////////////////////////// SecongPageCode.php <?php if (isset($_POST['$ID'])) { //$ID = $_REQUEST['ID']; echo "ID: $ID "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/208084-_post-_get-_request-problem/ Share on other sites More sharing options...
dreamwest Posted July 18, 2010 Share Posted July 18, 2010 $_GET or $_REQUEST can both pass info through urls Quote Link to comment https://forums.phpfreaks.com/topic/208084-_post-_get-_request-problem/#findComment-1087732 Share on other sites More sharing options...
andyjcurtis Posted July 18, 2010 Author Share Posted July 18, 2010 yes they can. I still get a blank secondpage though. Quote Link to comment https://forums.phpfreaks.com/topic/208084-_post-_get-_request-problem/#findComment-1087747 Share on other sites More sharing options...
wildteen88 Posted July 18, 2010 Share Posted July 18, 2010 This line in your secound page is wrong if (isset($_POST['$ID'])) $_POST['$ID'] should be $_GET['ID'] Quote Link to comment https://forums.phpfreaks.com/topic/208084-_post-_get-_request-problem/#findComment-1087748 Share on other sites More sharing options...
andyjcurtis Posted July 18, 2010 Author Share Posted July 18, 2010 thanks again for the pointers, I have tried using $_get and $_request, the secondpage still comes up blank? I think the data is not being sent across, though I am not sure where the problem is in the First page. Quote Link to comment https://forums.phpfreaks.com/topic/208084-_post-_get-_request-problem/#findComment-1087754 Share on other sites More sharing options...
wildteen88 Posted July 18, 2010 Share Posted July 18, 2010 thanks again for the pointers, I have tried using $_get and $_request, the secondpage still comes up blank? I think the data is not being sent across, though I am not sure where the problem is in the First page. What is the url you're using when going to the secound page? I am assuming you're url is something like http://localhost/CI/Buy.php?ID=123 (where 123 corresponds to a row in your database) In Buy.php you should be able to use if(isset($_GET['ID'])) { echo 'ID is: ' . $_GET['ID']; } Which should output something like ID is: 123 Quote Link to comment https://forums.phpfreaks.com/topic/208084-_post-_get-_request-problem/#findComment-1087756 Share on other sites More sharing options...
andyjcurtis Posted July 18, 2010 Author Share Posted July 18, 2010 dreamwest & wildteen88 Thank you so much, I really appreciate your help. The problem was I was using $_post where I shoud be using $_get or $_request in buy.php 2nd Problem was the 'ID is: 123' was not seen within my Echo href ......... I was seeing ID=?<?$ID?> Problem solved, I was not sending properly and not recieveing properly. ?> <td> <a href="http://localhost/CI/Buy.php?ID= <?=$ID?> "> <i>Buy</i></a> </td> <?; <?php if (isset($_GET['ID'])) { echo "<BR>ID: $ID"; echo '<BR>ID is: ' .$_GET['ID']; } ?> Have a :D each! thanks again Quote Link to comment https://forums.phpfreaks.com/topic/208084-_post-_get-_request-problem/#findComment-1087788 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.