[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

Using submit buttons/general script advice?

Hello,

I wondered if anyone could advise, I am trying to write a basic script to allow one of three submit buttons to be clicked. And then store the product quantity in session files.

I hoped also when we clicked <a href=""><img  src="forward.jpg"></a> the next script page would start.

I wondered if I was correct in using only one form, and could anyone advise how to move to the next page, when the forward.jpg is clicked?

I would much appreciate some guidance.

Thank you

<?php
session_start();

if(!isset($_SESSION['item1'])) $_SESSION['item1'] = 0;
if(!isset($_SESSION['item2'])) $_SESSION['item2'] = 0;
if(!isset($_SESSION['item3'])) $_SESSION['item3'] = 0;

if(isset($_POST['submit1'])){
  $_SESSION['item1']++;
}

if(isset($_POST['submit2'])){
  $_SESSION['item2']++;
}

if(isset($_POST['submit3'])){
  $_SESSION['item3']++;
}

?>

<html>
<head>
   <title>Exanple Script </title>
</head>

<body>
   <p>
   <table border="0" width="100%">
      <tr>
         <td align="center">
            <img  src="title.gif">
         </td>
         <td align="center">
            <a href=""><img  src="forward.jpg"></a>
         </td>
      </tr>
   </table>
   </p>

   <div align="center">
   <form method=post action="order.php">
   <table border="1" width="79%">
      <tr>
         <td rowspan=3>
            <center><img  src="product1.jpg">
         </td>
         <td>
            Dell Pentium Laptop
         </td>
         <td rowspan=3>
            <center><img  src="product2.jpg">
         </td>
         <td>
            Sony Desktop Pc
         </td>
      </tr>
      <tr>
         <td>
            £1000.00
         </td>
         <td>
            £1000.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit1" value = "Add to basket">
         </td>
         <td>
            <input type="submit" name = "submit2" value = "Add to basket">
         </td>
      </tr>
      <tr>
         <td rowspan=3>
            <center><img  src="product3.jpg">
         </td>
         <td>
            Dell X30 Handheld
         </td>
      </tr>
      <tr>
         <td>
            £400.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit3" value = "Add to basket">
         </td>
      </tr>
   </table>
   </form>
   </div>

</body>
</html>

0
AntoniRyszard656
Asked:
AntoniRyszard656
  • 15
  • 15
1 Solution
 
_GeG_Commented:
check with
if (!empty($_POST['submit1'])
    echo "submit button 1";
0
 
Diablo84Commented:
The way you are incrementing the session values depending on the button clicked looks fine to me.

With regards to

>> I hoped also when we clicked <a href=""><img  src="forward.jpg"></a> the next script page would start.

you could do something like this, replace:

            <a href=""><img  src="forward.jpg"></a>

with:

            <a href="<?php echo $_SERVER['PHP_SELF']; ?>?forward"><img  src="forward.jpg"></a>

then at the top of your script before the session content (after session_start()) would be best) add:

if (isset($_GET['forward'])) {
 header("location: next_page.php");
 exit;
}

replacing next_page.php with the name of the next page you want to show
0
 
AntoniRyszard656Author Commented:
Thank you for replying.

I made the changes, including removing the action statement from the form. When I clicked the icon associated with <a href="<?php echo $_SERVER['PHP_SELF']; ?>?forward"><img  src="mybasket.jpg"></a>

The order.php would not start, and I wondered if anyone could see the reason?

And could I ask, within the second page (order.php) if I add a icon to return to this first page. Would the user be able to add to the quantity of products in the existing session files? Or would return to this page, start new session files?

Thank you

<?php
session_start();

if (isset($_GET['forward'])) {
 header("order.php");
 exit;
}

if(!isset($_SESSION['item1'])) $_SESSION['item1'] = 0;
if(!isset($_SESSION['item2'])) $_SESSION['item2'] = 0;
if(!isset($_SESSION['item3'])) $_SESSION['item3'] = 0;

if(isset($_POST['submit1'])){
  $_SESSION['item1']++;
}

if(isset($_POST['submit2'])){
  $_SESSION['item2']++;
}

if(isset($_POST['submit3'])){
  $_SESSION['item3']++;
}

?>

<html>
<head>
   <title>Exanple Script </title>
</head>

<body>
   <p>
   <table border="0" width="100%">
      <tr>
         <td align="center">
            <img  src="title.gif">
         </td>
         <td align="center">
            <a href="<?php echo $_SERVER['PHP_SELF']; ?>?forward"><img  src="mybasket.jpg"></a>
         </td>
      </tr>
   </table>
   </p>

   <div align="center">
   <form method=post>
   <table border="1" width="79%">
      <tr>
         <td rowspan=3>
            <center><img  src="product1.jpg">
         </td>
         <td>
            Dell Pentium Laptop
         </td>
         <td rowspan=3>
            <center><img  src="product2.jpg">
         </td>
         <td>
            Sony Desktop Pc
         </td>
      </tr>
      <tr>
         <td>
            £1000.00
         </td>
         <td>
            £1000.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit1" value = "Add to basket">
         </td>
         <td>
            <input type="submit" name = "submit2" value = "Add to basket">
         </td>
      </tr>
      <tr>
         <td rowspan=3>
            <center><img  src="product3.jpg">
         </td>
         <td>
            Dell X30 Handheld
         </td>
      </tr>
      <tr>
         <td>
            £400.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit3" value = "Add to basket">
         </td>
      </tr>
   </table>
   </form>
   </div>

</body>
</html>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Diablo84Commented:
header("order.php");

should be

header("location: order.php");

>> Would the user be able to add to the quantity of products in the existing session files? Or would return to this page, start new session files?

sessions and there values are maintained all the time the session is active (until the user closes the browser window) so yes they would be able to add quantities to the exisitng count.
0
 
AntoniRyszard656Author Commented:
Hello,

I tried header("location: order.php");

Rather than the order.php script starting, the code of the current .php file was display.

Does this mean the order.php could not be found?

Thanks
0
 
Diablo84Commented:
quite possibly, is it in the same directory as the original script?

you could try:

header("location: ".$_SERVER['DOCUMENT_ROOT']."/path/to/order.php");
0
 
AntoniRyszard656Author Commented:
Thanks

My scripts are based in c:\php4win

Would this be correct?

header("location: ".$_SERVER['DOCUMENT_ROOT']."/c:/php4win/order.php")

Or in windows should I use .\c:\php4win\.order.php;

0
 
Diablo84Commented:
if c:\php4win is your document root then

header("location: ".$_SERVER['DOCUMENT_ROOT']."/order.php");

should work

or you could just use

header("location: c:/php4win/order.php")
0
 
AntoniRyszard656Author Commented:
Thanks

The changes did not seem to work, but I think the problem could be because, I am using the DzSoft php editor, which includes its own web server. I think I will need to install apache.

Did the script work for you, linking one of your scripts?

<?php
session_start();

if (isset($_GET['forward'])) {
 header("location: order.php");
 exit;
}

if(!isset($_SESSION['item1'])) $_SESSION['item1'] = 0;
if(!isset($_SESSION['item2'])) $_SESSION['item2'] = 0;
if(!isset($_SESSION['item3'])) $_SESSION['item3'] = 0;

if(isset($_POST['submit1'])){
  $_SESSION['item1']++;
}

if(isset($_POST['submit2'])){
  $_SESSION['item2']++;
}

if(isset($_POST['submit3'])){
  $_SESSION['item3']++;
}

?>

<html>
<head>
   <title>Exanple Script </title>
</head>

<body>
   <p>
   <table border="0" width="100%">
      <tr>
         <td align="center">
            <img  src="title.gif">
         </td>
         <td align="center">
            <a href="<?php echo $_SERVER['PHP_SELF']; ?>?forward"><img  src="mybasket.jpg"></a>
         </td>
      </tr>
   </table>
   </p>

   <div align="center">
   <form method=post>
   <table border="1" width="79%">
      <tr>
         <td rowspan=3>
            <center><img  src="product1.jpg">
         </td>
         <td>
            Dell Pentium Laptop
         </td>
         <td rowspan=3>
            <center><img  src="product2.jpg">
         </td>
         <td>
            Sony Desktop Pc
         </td>
      </tr>
      <tr>
         <td>
            £1000.00
         </td>
         <td>
            £1000.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit1" value = "Add to basket">
         </td>
         <td>
            <input type="submit" name = "submit2" value = "Add to basket">
         </td>
      </tr>
      <tr>
         <td rowspan=3>
            <center><img  src="product3.jpg">
         </td>
         <td>
            Dell X30 Handheld
         </td>
      </tr>
      <tr>
         <td>
            £400.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit3" value = "Add to basket">
         </td>
      </tr>
   </table>
   </form>
   </div>

</body>
</html>
0
 
Diablo84Commented:
yes works no problem for me.

To save going to too much trouble you could resort to using the meta refresh, eg:

<?php
session_start();

if(!isset($_SESSION['item1'])) $_SESSION['item1'] = 0;
if(!isset($_SESSION['item2'])) $_SESSION['item2'] = 0;
if(!isset($_SESSION['item3'])) $_SESSION['item3'] = 0;

if(isset($_POST['submit1'])){
  $_SESSION['item1']++;
}

if(isset($_POST['submit2'])){
  $_SESSION['item2']++;
}

if(isset($_POST['submit3'])){
  $_SESSION['item3']++;
}

?>

<html>
<head>
   <title>Exanple Script </title>
  <?php
    if (isset($_GET['forward']))  echo '<meta http-equiv="refresh" content="0;URL=order.php">';
   ?>
</head>

<body>
   <p>
   <table border="0" width="100%">
      <tr>
         <td align="center">
            <img  src="title.gif">
         </td>
         <td align="center">
            <a href="<?php echo $_SERVER['PHP_SELF']; ?>?forward"><img  src="mybasket.jpg"></a>
         </td>
      </tr>
   </table>
   </p>

   <div align="center">
   <form method=post>
   <table border="1" width="79%">
      <tr>
         <td rowspan=3>
            <center><img  src="product1.jpg">
         </td>
         <td>
            Dell Pentium Laptop
         </td>
         <td rowspan=3>
            <center><img  src="product2.jpg">
         </td>
         <td>
            Sony Desktop Pc
         </td>
      </tr>
      <tr>
         <td>
            £1000.00
         </td>
         <td>
            £1000.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit1" value = "Add to basket">
         </td>
         <td>
            <input type="submit" name = "submit2" value = "Add to basket">
         </td>
      </tr>
      <tr>
         <td rowspan=3>
            <center><img  src="product3.jpg">
         </td>
         <td>
            Dell X30 Handheld
         </td>
      </tr>
      <tr>
         <td>
            £400.00
         </td>
      </tr>
      <tr>
         <td>
            <input type="submit" name = "submit3" value = "Add to basket">
         </td>
      </tr>
   </table>
   </form>
   </div>

</body>
</html>
0
 
Diablo84Commented:
actually come to think of it i cannot see any real reason why you cant just directly link to the script

<a href="order.php"><img  src="forward.jpg"></a>
0
 
AntoniRyszard656Author Commented:
Many thanks, its working now.

Could I possibly ask about a second script?

Here the sctipt allows a user to enter there userid, password and pass these to a database method. The database part works I think, but I was hoping to display a message after the loginbox on the same page, to confirm the login was a success or not.

And wondered if it would possible to display the message after the loginbox, once the script is running. Or I would needed to start a new web page to display the message?

Thanks

<?php
include "usefulMethods.inc.php";

function login_form(){
?>
   <html>
   <head><title>Example script</title></head>
   <body>

   <div align="center">

   <form method="post">
      <table border="1">
         <tr>
            <th align="right">E-mail</th>
            <td nowrap>
               <input type"text" name="userid" size="25">
            </td>
         </tr>
         <tr>
            <th align="right">Password</th>
            <td nowrap>
               <input type="password" name="password" size="25">
            </td>
         </tr>
         <tr>
            <td align="center">
               <input type="submit" name="login" value="Login">
            </td>
         </tr>
      </table>
   </form>
   <div>
<?php
}

function login($userid, $password){
   $link_id = dbconnect();
   if(!$link_id) die(sql_error());

   $result = mysql_query("SELECT * FROM customer WHERE email = '$userid'
                       AND password = '$password'");

   if(!mysql_num_rows($result)) return 0;
   else
      $customer = mysql_fetch_row($result);
      return $customer;
}

login_form();

if(isset($_POST['login'])){
   exit;

   $userid = $_POST["userid"];
   $password = $_POST["password"];

   if(empty($userid) || empty($password)){
      error_message("All fields must be complete");
   }

   $customer = login($userid, $password);
}
?>
0
 
Diablo84Commented:
to save having to make things global and oiver complicating a simple process you might want to lose the second function and do something like this:

   <html>
   <head><title>Example script</title></head>
   <body>

<?php
include "usefulMethods.inc.php";

function login_form(){
?>
   <div align="center">

   <form method="post">
      <table border="1">
         <tr>
            <th align="right">E-mail</th>
            <td nowrap>
               <input type"text" name="userid" size="25">
            </td>
         </tr>
         <tr>
            <th align="right">Password</th>
            <td nowrap>
               <input type="password" name="password" size="25">
            </td>
         </tr>
         <tr>
            <td align="center">
               <input type="submit" name="login" value="Login">
            </td>
         </tr>
      </table>
   </form>
   <div>
<?php
}

function login($userid, $password){
   $link_id = dbconnect();
   if(!$link_id) die(sql_error());

   $result = mysql_query("SELECT * FROM customer WHERE email = '$userid'
                       AND password = '$password'");

   if(!mysql_num_rows($result)) return 0;
   else
      $customer = mysql_fetch_row($result);
      return $customer;
}

if(isset($_POST['login'])){
   $userid = $_POST["userid"];
   $password = $_POST["password"];

   if(empty($userid) || empty($password)){
      error_message("All fields must be complete");
   }

   $link_id = dbconnect();
   if(!$link_id) die(sql_error());

   $result = mysql_query("SELECT * FROM customer WHERE email = '$userid'
                       AND password = '$password'");

   if(mysql_num_rows($result) == 0) {
    $showform = true;
      $notif = "invalid login details";
   }
   else {
    $customer = mysql_fetch_row($result);
      $showform = false;
      $notif = "login successful";
   }
}
else {
 $showform = true;
}

if ($showform == true) login_form();
if(isset($notif)) echo $notif;
?>
0
 
AntoniRyszard656Author Commented:

Thanks again I will try this..

0
 
AntoniRyszard656Author Commented:
Thank you for replying.

When tested the script, I found the "invalid login" details" and "login successful" messages were not displayed after the loginbox.

Though I was unsure if the screen was just being refreshed straight after they were displayed, and so we never actually see the message?

Could you possibly test this on your system? I undertand you could not test the database.

Thank you
0
 
Diablo84Commented:
will do, bear with me...
0
 
Diablo84Commented:
I just tested with the following and it works fine (note i had to comment out some code i could not test and add a dummy if statement):

   <html>
   <head><title>Example script</title></head>
   <body>

<?php
//include "usefulMethods.inc.php";

function login_form(){
?>
   <div align="center">

   <form method="post">
      <table border="1">
         <tr>
            <th align="right">E-mail</th>
            <td nowrap>
               <input type"text" name="userid" size="25">
            </td>
         </tr>
         <tr>
            <th align="right">Password</th>
            <td nowrap>
               <input type="password" name="password" size="25">
            </td>
         </tr>
         <tr>
            <td align="center">
               <input type="submit" name="login" value="Login">
            </td>
         </tr>
      </table>
   </form>
   <div>
<?php
}

if(isset($_POST['login'])){
   $userid = $_POST["userid"];
   $password = $_POST["password"];

   if(empty($userid) || empty($password)){
      error_message("All fields must be complete");
   }

//   $link_id = dbconnect();
//   if(!$link_id) die(sql_error());

//   $result = mysql_query("SELECT * FROM customer WHERE email = '$userid'
//                       AND password = '$password'");

//   if(mysql_num_rows($result) == 0) {
   if($userid != 1 || $password != "password") {
     $showform = true;
     $notif = "invalid login details";
   }
   else {
//    $customer = mysql_fetch_row($result);
     $showform = false;
     $notif = "login successful";
   }
}
else {
 $showform = true;
}

if ($showform == true) login_form();
if(isset($notif)) echo $notif;
?>

Is there more code then what is featured above on your page, if so il need to see it...
0
 
AntoniRyszard656Author Commented:
Thanks

I copied your script and created a php file, when I entered 1 and password  and clicked the login submit button.

The screen was just refrshed, showing a new loginbox without any values.

And no matter what values I entered the screen was just refreshed. As if the entire script was being re-loaded.

As I mentioned I am using the DzSoft php editor and its internal web browser. So perhaps the problem is with this software.

I am correct saying on your system the "invalid login details", or "login successful" message is display underneath the loginbox?. And if you tried the loginbox for a second time, the screen would refresh and show the new message, at the position of the orginal?

Thanks
0
 
Diablo84Commented:
Heres the flow of the script, you submit the form with incorrect details and "invalid login details" will display below the form, if you submit the form with the correct login details it displays "login successful" below the form.

There is no problem with this script so it looks to be a limitation of DzSoft, im not familiar with this program but i cannot see how it could correctly test php anyway frankly. I advise you install Apache 1.3 (http://httpd.apache.org/) and php v5 (http://www.php.net) so you can test your code properly.
0
 
AntoniRyszard656Author Commented:
I looked at the apache site, and currently download from this link.

I am using win98 at the moment, should I be-able to use apache with this old version of windows?

http://www.mirror.ac.uk/mirror/ftp.apache.org/httpd/binaries/win32/apache_1.3.31-win32-x86-no_src.exe

0
 
Diablo84Commented:
From the manual:

"Requirements

Apache 1.3 is designed to run on Windows NT 4.0 and Windows 2000. The binary installer will only work with the x86 family of processors, such as Intel's. Apache may also run on Windows 95 and 98, but these have not been tested. In all cases TCP/IP networking must be installed.

If running on NT 4.0, installing Service Pack 3 or 6 is recommended, as Service Pack 4 created known issues with TCP/IP and WinSock integrity that were resolved in Service Pack 5 and later.

Note: "Winsock2" is required for Apache 1.3.7 and later.

If running on Windows 95, the "Winsock2" upgrade must be installed before Apache will run. "Winsock2" for Windows 95 is available here or via here. Be warned that the Dialup Networking 1.2 (MS DUN) updates include a Winsock2 that is entirely insufficient, and the Winsock2 update must be reinstalled after installing Windows 95 dialup networking. Windows 98, NT (Service Pack 3 or later) and 2000 users need to take no special action, those versions provide Winsock2 as distributed."
0
 
AntoniRyszard656Author Commented:
Hello,

I managed to install apache and run this as a console.

I got this error, and wondered you had seen this error before?

Method Not Allowed
The requested method POST is not allowed for the URL /temp.php.


--------------------------------------------------------------------------------

Apache/1.3.31 Server at n5q8k1.aoldsl.net Port 80
0
 
AntoniRyszard656Author Commented:
Hello,

I will look at the apache documentation, to resolve the problem using POST.

I just wondered if  could finally ask, in my orginal script if I wanted to replace the submit buttons with icons would I need to change the (form) method to equal "GET", and change the  if(isset($_POST['submit1'])){ to $_GET?

I have added the href code here for the icons.

Thank you

<?php
session_start();

if(!isset($_SESSION['item1'])) $_SESSION['item1'] = 0;
if(!isset($_SESSION['item2'])) $_SESSION['item2'] = 0;
if(!isset($_SESSION['item3'])) $_SESSION['item3'] = 0;

if(isset($_POST['submit1'])){
  $_SESSION['item1']++;
}

if(isset($_POST['submit2'])){
  $_SESSION['item2']++;
}

if(isset($_POST['submit3'])){
  $_SESSION['item3']++;
}

?>

<html>
<head>
   <title>Exanple Script </title>
</head>

<body>
   <p>
   <table border="0" width="100%">
      <tr>
         <td align="center">
            <img  src="title.gif">
         </td>
         <td align="center">
            <a href="order.php"><img  src="mybasket.jpg"></a>  >
         </td>
      </tr>
   </table>
   </p>

   <div align="center">
   <form method=post>
   <table border="1" width="79%">
      <tr>
         <td rowspan=3>
            <center><img  src="product1.jpg">
         </td>
         <td>
            Dell Pentium Laptop
         </td>
         <td rowspan=3>
            <center><img  src="product2.jpg">
         </td>
         <td>
            Sony Desktop Pc
         </td>
      </tr>
      <tr>
         <td>
            £1000.00
         </td>
         <td>
            £1000.00
         </td>
      </tr>
      <tr>
         <td>
            //<input type="submit" name = "submit1" value = "Add to basket">
          <a href="<?php echo $_SERVER['PHP_SELF']; ?>?submit1"><img  src="submit.jpg"></a
         </td>
         <td>
            //<input type="submit" name = "submit2" value = "Add to basket">
          <a href="<?php echo $_SERVER['PHP_SELF']; ?>?submit2"><img  src="submit.jpg"></a
         </td>
      </tr>
      <tr>
         <td rowspan=3>
            <center><img  src="product3.jpg">
         </td>
         <td>
            Dell X30 Handheld
         </td>
      </tr>
      <tr>
         <td>
            £400.00
         </td>
      </tr>
      <tr>
         <td>
            //<input type="submit" name = "submit3" value = "Add to basket">
        <a href="<?php echo $_SERVER['PHP_SELF']; ?>?submit3"><img  src="submit.jpg"></a>
         </td>
      </tr>
   </table>
   </form>
   </div>

</body>
</html>
0
 
Diablo84Commented:
I wouldn't have thought so, just add some JS to the image link and carry on with the post method

<a href="javascript:void(document.form_name.submit())"><img src="imagesjpg"></a>


Incidentally for future reference the protocol is strictly one question per thread, i don't mind so much myself but there will be contributors who are less favourable towards it :)

http://www.experts-exchange.com/Community_Support/help.jsp#hi107


Good Luck with your code
0
 
AntoniRyszard656Author Commented:
Its just that you recommended eariler, the use of GET with the first href to move to the order script. And I was unsure why, we use $_GET when testing for href, and $_POST for submits?

if (isset($_GET['forward'])) {
}

If I used the code below, instead of the sumit buttons would I be able to remove the form and replace the post if statements with get? Is this more correct than using POST?

<a href="<?php echo $_SERVER['PHP_SELF']; ?>?submit1"><img  src="submit.jpg"></a

Sorry for going back to my orginal question.

<?php
session_start();

if(!isset($_SESSION['item1'])) $_SESSION['item1'] = 0;
if(!isset($_SESSION['item2'])) $_SESSION['item2'] = 0;
if(!isset($_SESSION['item3'])) $_SESSION['item3'] = 0;

if(isset($_GET['submit1'])){
  $_SESSION['item1']++;
}

if(isset($_GET['submit2'])){
  $_SESSION['item2']++;
}

if(isset($_GET['submit3'])){
  $_SESSION['item3']++;
}

?>

<html>
<head>
   <title>Exanple Script </title>
</head>

<body>
   <p>
   <table border="0" width="100%">
      <tr>
         <td align="center">
            <img  src="title.gif">
         </td>
         <td align="center">
            <a href="order.php"><img  src="mybasket.jpg"></a>  >
         </td>
      </tr>
   </table>
   </p>

   <div align="center">

   <table border="1" width="79%">
      <tr>
         <td rowspan=3>
            <center><img  src="product1.jpg">
         </td>
         <td>
            Dell Pentium Laptop
         </td>
         <td rowspan=3>
            <center><img  src="product2.jpg">
         </td>
         <td>
            Sony Desktop Pc
         </td>
      </tr>
      <tr>
         <td>
            £1000.00
         </td>
         <td>
            £1000.00
         </td>
      </tr>
      <tr>
         <td>
          <a href="<?php echo $_SERVER['PHP_SELF']; ?>?submit1"><img  src="submit.jpg"></a
         </td>
         <td>
          <a href="<?php echo $_SERVER['PHP_SELF']; ?>?submit2"><img  src="submit.jpg"></a
         </td>
      </tr>
      <tr>
         <td rowspan=3>
            <center><img  src="product3.jpg">
         </td>
         <td>
            Dell X30 Handheld
         </td>
      </tr>
      <tr>
         <td>
            £400.00
         </td>
      </tr>
      <tr>
         <td>
        <a href="<?php echo $_SERVER['PHP_SELF']; ?>?submit3"><img  src="submit.jpg"></a>
         </td>
      </tr>
   </table>

   </div>

</body>
</html>
0
 
Diablo84Commented:
Basically GET is used to retrieve variables from the url query string and POST is used to retrive post data from the http headers.

Forms can be set to use either POST or GET (method="post" or method="get") so with post the data from the form will be sent in the http headers (invisible to the user) where as with get the data from the form will be sent in the query string. Hyperlink query strings use the get method.
0
 
AntoniRyszard656Author Commented:
Thanks

I think in the login script I should use POST because it seems more secure, but in this first script is there any reason to use POST rather than GET.

If I use href rather than the submit buttons, would be better to use GET?
0
 
Diablo84Commented:
Never use GET for login scripts because the password will be passed in the url, obviously not a good idea.

If you use the JavaScript  you can use an image as the submit button which can still use the post method.

eg

<img src="image.jpg" onClick="document.forms.FORM_NAME.submit();">
0
 
AntoniRyszard656Author Commented:
Thanks

I just thought generally it would be better to use html so the code will work in any browser.  

I will use post with the login, but you would also recommend this in the script which allows three products to be selected?

0
 
Diablo84Commented:
Where form data is concerned always use the post method unless there is a specific reason why you want the data stored in the query string
0
 
AntoniRyszard656Author Commented:

Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 15
  • 15
Tackle projects and never again get stuck behind a technical roadblock.
Join Now