Solved

Using submit buttons/general script advice?

Posted on 2004-08-31
31
265 Views
Last Modified: 2008-03-03
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
Comment
Question by:AntoniRyszard656
  • 15
  • 15
31 Comments
 
LVL 9

Expert Comment

by:_GeG_
ID: 11947300
check with
if (!empty($_POST['submit1'])
    echo "submit button 1";
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11947498
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
 

Author Comment

by:AntoniRyszard656
ID: 11951209
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11951235
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
 

Author Comment

by:AntoniRyszard656
ID: 11951563
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11951583
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
 

Author Comment

by:AntoniRyszard656
ID: 11951742
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11951778
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
 

Author Comment

by:AntoniRyszard656
ID: 11951926
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11951998
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
 
LVL 27

Accepted Solution

by:
Diablo84 earned 65 total points
ID: 11952016
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
 

Author Comment

by:AntoniRyszard656
ID: 11952315
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11952618
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
 

Author Comment

by:AntoniRyszard656
ID: 11952729

Thanks again I will try this..

0
 

Author Comment

by:AntoniRyszard656
ID: 11962095
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 27

Expert Comment

by:Diablo84
ID: 11962540
will do, bear with me...
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11962578
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
 

Author Comment

by:AntoniRyszard656
ID: 11963059
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11963120
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
 

Author Comment

by:AntoniRyszard656
ID: 11963219
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11963510
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
 

Author Comment

by:AntoniRyszard656
ID: 11971650
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
 

Author Comment

by:AntoniRyszard656
ID: 11974040
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11974192
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
 

Author Comment

by:AntoniRyszard656
ID: 11976159
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11976818
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
 

Author Comment

by:AntoniRyszard656
ID: 11976950
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11977000
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
 

Author Comment

by:AntoniRyszard656
ID: 11977076
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11977111
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
 

Author Comment

by:AntoniRyszard656
ID: 11977156

Thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now