SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Form checkbox and dropdown array help

    So I started making a new page in PHP for a simple order form. One where you check the pictures you want and then select the size. After which you enter in some personal info and get mailed an invoice. A few problems arose which I have fixed, but now a few more have arisen, the biggest is for some reason my checkbox and dropdown array won't store the data and when it's supposed to check to verify there is at least 1 selected of each nothing happens...I just get an error......

    To be honest the ideal thing would be to have it check to see if the drop down size selection below the checkbox was selected, but I'll do whatever as long as it works.

    Also side note, is there a simple way to req email or street address (not bothm just whichever they decide to fill out?) <-- Not a big deal, but if I can make my page sexier, why not right...

    Thanks ahead of time for the help.

    Here's my page code:

    Code:
    <html>
    <HEAD>
    </head>
    <body>
    <?php
    require_once "formvalidator.php";
      $error_hash = 'no';
      $show_form = true;
    class MyValidator extends CustomValidator
    {
    	function DoValidate(&$formars,&$error_hash)
    	{
            if(stristr($formars['comments'],'http://'))
            {
                $error_hash['comments']="No URLs allowed in comments";
                return false;
            }
    		return true;
    	}
    }
      if ($_SERVER['REQUEST_METHOD'] == "POST") {
    
          $validator = new FormValidator();
          $validator->addValidation("email", "email", "<B>Email address is invalid.</B>");
          $validator->addValidation("first", "req", "<B>Please provide your First name for invoice.</B>");
          $validator->addValidation("last", "req", "<B>Please provide your Last name for invoice.</B>");
          $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>");
          $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>");
          $validator->addValidation("state", "req", "<B>Please provide your State for invoice.</B>");
          $validator->addValidation("zip", "num", "req", "<B>Please provide your zip for invoice.</B>");
          $validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>");
          if ($validator->ValidateForm()) {
              $show_form = false;
          } else {
              echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>";
              $error_hash = $validator->GetErrors();
              foreach ($error_hash as $inpname => $inp_err) {
                  echo "<center><p>$inpname : $inp_err</p></center>\n";
                  $show_form = true;
              }
          }
    $pic = $_POST['pic'];
    if(empty($pic)) 
      {
        echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
      } 
      else 
      {
        $r = count($pic);
        for($i=0; $i < $r; $i++)
        {
          echo "picture(s) requested $i was: " . $pic[$i] . "\r\n";
        }
      }
    
    $size = $_POST['size'];
    if(empty($size)) 
      {
        echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; 
      } 
      else 
      {
        $r = count($size);
        for($i=0; $i < $r; $i++)
        {
          echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
        }
      }
              if ($show_form === false){
              // Grab the form vars
    	  $Pic = $_POST['pic'] ;
    	  $Size = $_POST['size'] ;
              $Email = $_POST['email'];
              $Name = $_POST['first'. 'last'];
              $Addr = $_POST['addr'];
              $City = $_POST['city'];
              $State = $_POST['state'];
              $Zip = $_POST['zip'];
    	  $comments = $_POST['comments'] ;
     
    
    
            //message body
            $mail_body .= "$Pic"."\r\n";
            $mail_body .= "$Size"."\r\n";
            $mail_body .= "$Email"."\r\n";
            $mail_body .= "$Name"."\r\n";
            $mail_body .= "$Addr"."\r\n";
            $mail_body .= "$City,". " $State". " $Zip"."\r\n";
            $mail_body .= "$Comments"."\r\n";
            //sending to
            $recipient = "hakarune@gmail.com";
            $subject = "Order Form";
            //Headerfields
            $header = "From: " . $Email . " <" . $Email . ">\r\n";
            //mail command
            mail($recipient, $subject, $mail_body, $header);
                                       
              echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in 10 seconds...</div>";
                            //page redirect to home
                                             echo "<META HTTP-EQUIV=\"refresh\" content=\"10;URL=buttontest3.php\">";
    	
      }
    }
      if (true == $show_form) {
    ?>
    
    <form name="ordering" action="" method="POST">
    <img src="1.jpg" />
    <input type="checkbox" name="pic[]" value="1">
    <br />
    <select name="Type" size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="Original">Original $Price</option>
      <option value="Print Small">300x500 Print $Price</option>
     <option value="Print Medium">800x600 Print $Price</option>
     <option value="Print Large">1200x1280 Print $Price</option>
     <option value="Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="2.jpg" />
    <input type="checkbox" name="pic[]" value="2">
    <br />
    <select name="Type" size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="Original">Original $Price</option>
      <option value="Print Small">300x500 Print $Price</option>
     <option value="Print Medium">800x600 Print $Price</option>
     <option value="Print Large">1200x1280 Print $Price</option>
     <option value="Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="3.jpg" />
    <input type="checkbox" name="pic[]" Value="3">
    <br />
    <select name="Type" size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="Original">Original $Price</option>
      <option value="Print Small">300x500 Print $Price</option>
     <option value="Print Medium">800x600 Print $Price</option>
     <option value="Print Large">1200x1280 Print $Price</option>
     <option value="Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="4.jpg" />
    <input type="checkbox" name="pic[]" value="4">
    <br />
    <select name="Type" size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="Original">Original $Price</option>
      <option value="Print Small">300x500 Print $Price</option>
     <option value="Print Medium">800x600 Print $Price</option>
     <option value="Print Large">1200x1280 Print $Price</option>
     <option value="Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="5.jpg" />
    <input type="checkbox" name="pic[]" value="5">
    <br />
    <select name="Type" size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="Original">Original $Price</option>
      <option value="Print Small">300x500 Print $Price</option>
     <option value="Print Medium">800x600 Print $Price</option>
     <option value="Print Large">1200x1280 Print $Price</option>
     <option value="Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <br />
    <br />
    Information For Invoice: <font color="red">(Required Info = *)</font>
    <br />
    <input type="text" name="first" Value="First Name" size="25" onfocus="value=''"><font 
    
    color="red">*</font>
    <input type="text" name="last" Value="Last Name" size="25" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <input type="text" name="phone" Value="phone Number" size="25" onfocus="value=''">
    <br />
    <input type="text" name="email" Value="E-mail" size="30" onfocus="value=''">
    <br />
    <input type="text" name="addr" Value="Street Address" size="50" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <input type="text" name="city" Value="city" size="30" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <select name="state" size="1">
    	<option value="">Select State</option>
    	<option value="AK">AK</option>
    	<option value="AL">AL</option>
    	<option value="AR">AR</option>
    	<option value="AZ">AZ</option>
    	<option value="CA">CA</option>
    	<option value="CO">CO</option>
    	<option value="CT">CT</option>
    	<option value="DC">DC</option>
    	<option value="DE">DE</option>
    	<option value="FL">FL</option>
    	<option value="GA">GA</option>
    	<option value="HI">HI</option>
    	<option value="IA">IA</option>
    	<option value="ID">ID</option>
    	<option value="IL">IL</option>
    	<option value="IN">IN</option>
    	<option value="KS">KS</option>
    	<option value="KY">KY</option>
    	<option value="LA">LA</option>
    	<option value="MA">MA</option>
    	<option value="MD">MD</option>
    	<option value="ME">ME</option>
    	<option value="MI">MI</option>
    	<option value="MN">MN</option>
    	<option value="MO">MO</option>
    	<option value="MS">MS</option>
    	<option value="MT">MT</option>
    	<option value="NC">NC</option>
    	<option value="ND">ND</option>
    	<option value="NE">NE</option>
    	<option value="NH">NH</option>
    	<option value="NJ">NJ</option>
    	<option value="NM">NM</option>
    	<option value="NV">NV</option>
    	<option value="NY">NY</option>
    	<option value="OH">OH</option>
    	<option value="OK">OK</option>
    	<option value="OR">OR</option>
    	<option value="PA">PA</option>
    	<option value="RI">RI</option>
    	<option value="SC">SC</option>
    	<option value="SD">SD</option>
    	<option value="TN">TN</option>
    	<option value="TX">TX</option>
    	<option value="UT">UT</option>
    	<option value="VA">VA</option>
    	<option value="VT">VT</option>
    	<option value="WA">WA</option>
    	<option value="WI">WI</option>
    	<option value="WV">WV</option>
    	<option value="WY">WY</option>
    </select>
    <br />
    <input type="text" name="zip" Value="Zipcode" size="5" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <textarea name="comments" rows="5" cols="20" value="comments" onfocus="value=''">
      </textarea>
    <br />
    <input type="Submit" value="Submit">
    <input type="reset" value="Clear Form">
    </form>
    <?php
          }//true == $show_form
    ?>
    </body>
    </html>

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You did notice that you named several of your dropdowns the same? Not to mention that you specified "name" attribute more than once per dropdown. Start from there, and paste what error you get, it should be easier to debug like that.

  3. #3
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    Quote Originally Posted by furicane View Post
    You did notice that you named several of your dropdowns the same? Not to mention that you specified "name" attribute more than once per dropdown. Start from there, and paste what error you get, it should be easier to debug like that.
    /facepalm Damnit, how'd I do that and not even see it???? WTF....Umm, don't tell no one lol.. ok, fixed the code and retested... still getting an error, but it appears data is being collected (I think...)

    ok so here's the error:
    ( ! ) Notice: Undefined index: pic in C:\Users\Portgas D Ace\Documents\My Web Sites\Bristow Galleries\orderform\buttontest3.php on line 42
    Call Stack
    # Time Memory Function Location
    1 0.0044 375072 {main}( ) ..\buttontest3.php:0
    Dump $_SERVER
    $_SERVER['REMOTE_ADDR'] =
    string '127.0.0.1' (length=9)
    $_SERVER['REQUEST_METHOD'] =
    string 'POST' (length=4)
    $_SERVER['REQUEST_URI'] =
    string '/bristowgalleries/orderform/buttontest3.php' (length=43)
    Variables in local scope (#1)
    $Addr =
    Undefined
    $City =
    Undefined
    $Comments =
    Undefined
    $Email =
    Undefined
    $Name =
    Undefined
    $Pic =
    Undefined
    $Size =
    Undefined
    $State =
    Undefined
    $Zip =
    Undefined
    $comments =
    Undefined
    $error_hash =
    array
    'email' => string '<B>Email address is invalid.</B>' (length=32)
    'state' => string '<B>Please provide your State for invoice.</B>' (length=45)
    $header =
    Undefined
    $i =
    Undefined
    $inp_err =
    string '<B>Please provide your State for invoice.</B>' (length=45)
    $inpname =
    string 'state' (length=5)
    $mail_body =
    Undefined
    $pic =
    Undefined
    $r =
    Undefined
    $recipient =
    Undefined
    $show_form =
    boolean true
    $size =
    Undefined
    $subject =
    Undefined
    $validator =
    object(FormValidator)[1]
    public 'validator_array' =>
    array
    0 =>
    object(ValidatorObj)[2]
    public 'variable_name' => string 'email' (length=5)
    public 'validator_string' => string 'email' (length=5)
    public 'error_string' => string '<B>Email address is invalid.</B>' (length=32)
    1 =>
    object(ValidatorObj)[3]
    public 'variable_name' => string 'first' (length=5)
    public 'validator_string' => string 'req' (length=3)
    public 'error_string' => string '<B>Please provide your First name for invoice.</B>' (length=50)
    2 =>
    object(ValidatorObj)[4]
    public 'variable_name' => string 'last' (length=4)
    public 'validator_string' => string 'req' (length=3)
    public 'error_string' => string '<B>Please provide your Last name for invoice.</B>' (length=49)
    3 =>
    object(ValidatorObj)[5]
    public 'variable_name' => string 'addr' (length=4)
    public 'validator_string' => string 'req' (length=3)
    public 'error_string' => string '<B>Please provide your address for invoice.</B>' (length=47)
    4 =>
    object(ValidatorObj)[6]
    public 'variable_name' => string 'city' (length=4)
    public 'validator_string' => string 'req' (length=3)
    public 'error_string' => string '<B>Please provide your city name for invoice.</B>' (length=49)
    5 =>
    object(ValidatorObj)[7]
    public 'variable_name' => string 'state' (length=5)
    public 'validator_string' => string 'req' (length=3)
    public 'error_string' => string '<B>Please provide your State for invoice.</B>' (length=45)
    6 =>
    object(ValidatorObj)[8]
    public 'variable_name' => string 'zip' (length=3)
    public 'validator_string' => string 'num' (length=3)
    public 'error_string' => string 'req' (length=3)
    7 =>
    object(ValidatorObj)[9]
    public 'variable_name' => string 'phone' (length=5)
    public 'validator_string' => string 'num' (length=3)
    public 'error_string' => string '<B>Numbers only in phone number.</B>' (length=36)
    public 'error_hash' =>
    array
    'email' => string '<B>Email address is invalid.</B>' (length=32)
    'state' => string '<B>Please provide your State for invoice.</B>' (length=45)
    public 'custom_validators' =>
    array
    empty
    Line 42 is:
    Code:
    $pic = $_POST['pic'];
    and here is what I mean by I think data is being collected:
    Please Select a picture.
    Sizes(s) requested 0 was: Sizes(s) requested 1 was: Sizes(s) requested 2 was: Sizes(s) requested 3 was: Sizes(s) requested 4 was:
    ^-- 1st part is the null checkbox validation error (think it's working right)...
    an the second I haven't seen before but corresponding with the dropdowns...

    here's the new code:
    Code:
    <?php
    require_once "formvalidator.php";
      $error_hash = 'no';
      $show_form = true;
    class MyValidator extends CustomValidator
    {
    	function DoValidate(&$formars,&$error_hash)
    	{
            if(stristr($formars['comments'],'http://'))
            {
                $error_hash['comments']="No URLs allowed in comments";
                return false;
            }
    		return true;
    	}
    }
      if ($_SERVER['REQUEST_METHOD'] == "POST") {
    
          $validator = new FormValidator();
          $validator->addValidation("email", "email", "<B>Email address is invalid.</B>");
          $validator->addValidation("first", "req", "<B>Please provide your First name for invoice.</B>");
          $validator->addValidation("last", "req", "<B>Please provide your Last name for invoice.</B>");
          $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>");
          $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>");
          $validator->addValidation("state", "req", "<B>Please provide your State for invoice.</B>");
          $validator->addValidation("zip", "num", "req", "<B>Please provide your zip for invoice.</B>");
          $validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>");
          if ($validator->ValidateForm()) {
              $show_form = false;
          } else {
              echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>";
              $error_hash = $validator->GetErrors();
              foreach ($error_hash as $inpname => $inp_err) {
                  echo "<center><p>$inpname : $inp_err</p></center>\n";
                  $show_form = true;
              }
          }
    $pic = $_POST['pic'];
    if(empty($pic)) 
      {
        echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
      } 
      else 
      {
        $r = count($pic);
        for($i=0; $i < $r; $i++)
        {
          echo "picture(s) requested $i was: " . $pic[$i] . "\r\n";
        }
      }
    
    $size = $_POST['size'];
    if(empty($size)) 
      {
        echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; 
      } 
      else 
      {
        $r = count($size);
        for($i=0; $i < $r; $i++)
        {
          echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
        }
      }
              if ($show_form === false){
              // Grab the form vars
    	  $Pic = $_POST['pic'] ;
    	  $Size = $_POST['size'] ;
              $Email = $_POST['email'];
              $Name = $_POST['first'. 'last'];
              $Addr = $_POST['addr'];
              $City = $_POST['city'];
              $State = $_POST['state'];
              $Zip = $_POST['zip'];
    	  $comments = $_POST['comments'] ;
     
    
    
            //message body
            $mail_body .= "$Pic"."\r\n";
            $mail_body .= "$Size"."\r\n";
            $mail_body .= "$Email"."\r\n";
            $mail_body .= "$Name"."\r\n";
            $mail_body .= "$Addr"."\r\n";
            $mail_body .= "$City,". " $State". " $Zip"."\r\n";
            $mail_body .= "$Comments"."\r\n";
            //sending to
            $recipient = "hakarune@gmail.com";
            $subject = "Order Form";
            //Headerfields
            $header = "From: " . $Email . " <" . $Email . ">\r\n";
            //mail command
            mail($recipient, $subject, $mail_body, $header);
                                       
              echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in 10 seconds...</div>";
                            //page redirect to home
                                             echo "<META HTTP-EQUIV=\"refresh\" content=\"10;URL=buttontest3.php\">";
    	
      }
    }
      if (true == $show_form) {
    ?>
    
    <form name="ordering" action="" method="POST">
    <img src="1.jpg" />
    <input type="checkbox" name="pic[]" value="1">
    <br />
    <select size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="pic1_Original">Original $Price</option>
      <option value="pic1_Print Small">300x500 Print $Price</option>
      <option value="pic1_Print Medium">800x600 Print $Price</option>
      <option value="pic1_Print Large">1200x1280 Print $Price</option>
      <option value="pic1_Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="2.jpg" />
    <input type="checkbox" name="pic[]" value="2">
    <br />
    <select size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="pic2_Original">Original $Price</option>
      <option value="pic2_Print Small">300x500 Print $Price</option>
      <option value="pic2_Print Medium">800x600 Print $Price</option>
      <option value="pic2_Print Large">1200x1280 Print $Price</option>
      <option value="pic2_Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="3.jpg" />
    <input type="checkbox" name="pic[]" Value="3">
    <br />
    <select nsize="1" name="size[]">
      <option value="">Select Type</option>
      <option value="pic3_Original">Original $Price</option>
      <option value="pic3_Print Small">300x500 Print $Price</option>
      <option value="pic3_Print Medium">800x600 Print $Price</option>
      <option value="pic3_Print Large">1200x1280 Print $Price</option>
      <option value="pic3_Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="4.jpg" />
    <input type="checkbox" name="pic[]" value="4">
    <br />
    <select size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="pic4_Original">Original $Price</option>
      <option value="pic4_Print Small">300x500 Print $Price</option>
      <option value="pic4_Print Medium">800x600 Print $Price</option>
      <option value="pic4_Print Large">1200x1280 Print $Price</option>
      <option value="pic4_Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <img src="5.jpg" />
    <input type="checkbox" name="pic[]" value="5">
    <br />
    <select size="1" name="size[]">
      <option value="">Select Type</option>
      <option value="pic5_Original">Original $Price</option>
      <option value="pic5_Print Small">300x500 Print $Price</option>
      <option value="pic5_Print Medium">800x600 Print $Price</option>
      <option value="pic5_Print Large">1200x1280 Print $Price</option>
      <option value="pic5_Print XLarge">1282x1400 Print $Price</option>
    </select>
    <br />
    <br />
    <br />
    Information For Invoice: <font color="red">(Required Info = *)</font>
    <br />
    <input type="text" name="first" Value="First Name" size="25" onfocus="value=''"><font 
    
    color="red">*</font>
    <input type="text" name="last" Value="Last Name" size="25" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <input type="text" name="phone" Value="phone Number" size="25" onfocus="value=''">
    <br />
    <input type="text" name="email" Value="E-mail" size="30" onfocus="value=''">
    <br />
    <input type="text" name="addr" Value="Street Address" size="50" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <input type="text" name="city" Value="city" size="30" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <select name="state" size="1">
    	<option value="">Select State</option>
    	<option value="AK">AK</option>
    	<option value="AL">AL</option>
    	<option value="AR">AR</option>
    	<option value="AZ">AZ</option>
    	<option value="CA">CA</option>
    	<option value="CO">CO</option>
    	<option value="CT">CT</option>
    	<option value="DC">DC</option>
    	<option value="DE">DE</option>
    	<option value="FL">FL</option>
    	<option value="GA">GA</option>
    	<option value="HI">HI</option>
    	<option value="IA">IA</option>
    	<option value="ID">ID</option>
    	<option value="IL">IL</option>
    	<option value="IN">IN</option>
    	<option value="KS">KS</option>
    	<option value="KY">KY</option>
    	<option value="LA">LA</option>
    	<option value="MA">MA</option>
    	<option value="MD">MD</option>
    	<option value="ME">ME</option>
    	<option value="MI">MI</option>
    	<option value="MN">MN</option>
    	<option value="MO">MO</option>
    	<option value="MS">MS</option>
    	<option value="MT">MT</option>
    	<option value="NC">NC</option>
    	<option value="ND">ND</option>
    	<option value="NE">NE</option>
    	<option value="NH">NH</option>
    	<option value="NJ">NJ</option>
    	<option value="NM">NM</option>
    	<option value="NV">NV</option>
    	<option value="NY">NY</option>
    	<option value="OH">OH</option>
    	<option value="OK">OK</option>
    	<option value="OR">OR</option>
    	<option value="PA">PA</option>
    	<option value="RI">RI</option>
    	<option value="SC">SC</option>
    	<option value="SD">SD</option>
    	<option value="TN">TN</option>
    	<option value="TX">TX</option>
    	<option value="UT">UT</option>
    	<option value="VA">VA</option>
    	<option value="VT">VT</option>
    	<option value="WA">WA</option>
    	<option value="WI">WI</option>
    	<option value="WV">WV</option>
    	<option value="WY">WY</option>
    </select>
    <br />
    <input type="text" name="zip" Value="Zipcode" size="5" onfocus="value=''"><font 
    
    color="red">*</font>
    <br />
    <textarea name="comments" rows="5" cols="20" value="comments" onfocus="value=''">
      </textarea>
    <br />
    <input type="Submit" value="Submit">
    <input type="reset" value="Clear Form">
    </form>
    <?php
          }//true == $show_form
    ?>

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Using the isset() function is standard practise these days when working with $_GET and $_POST values, change you code to

    PHP Code:
    $pic = isset($_POST['pic']) ? $_POST['pic'] : false

  5. #5
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SgtLegend View Post
    Using the isset() function is standard practise these days when working with $_GET and $_POST values, change you code to

    PHP Code:
    $pic = isset($_POST['pic']) ? $_POST['pic'] : false
    So, i don't fully understand what this does.... I get if sets a value for $pic and has the placeholder to memorize the different values, but what's the rest?

  6. #6
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I get it now, all good.

    But for some reason

    [code]
    $size = isset($_POST['size']) ? $_POST['size'] : false; //$_POST['size'];
    if(empty($size))
    {
    echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>";
    }
    else
    {
    $r = count($size);
    for($i=0; $i < $r; $i++)
    {
    echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
    }
    [code]

    with:

    Code:
    <select size="1" name="size[]">
      <option>Select Type</option>
      <option value="pic1_Original">Original $Price</option>
      <option value="pic1_300x500 Print">300x500 Print $Price</option>
      <option value="pic1_800x600 Print">800x600 Print $Price</option>
      <option value="pic1_1200x1280 Print">1200x1280 Print $Price</option>
      <option value="pic1_1282x1400 Print">1282x1400 Print $Price</option>
    </select>
    with "Select Size" selected (value is empty) it shows:
    picture(s) requested 0 was: 1 Sizes(s) requested 0 was: Select Type Sizes(s) requested 1 was: Select Type Sizes(s) requested 2 was: Select Type Sizes(s) requested 3 was: Select Type Sizes(s) requested 4 was: Select Type

  7. #7
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    How exactly does your select box work as to me it looks like you need to set multiple="multiple" on the select element


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •