Jump to content

$_POST $_GET $_REQuest Problem


andyjcurtis

Recommended Posts

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 ";

}

?>

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 :D

each!

 

thanks again

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.