Jump to content

maciek4

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by maciek4

  1. I have a form where I have a field with 4 radio buttons containing options: A B C D The field is required so if no option is selected then an error message appears in red color. When the user selects one option and clicks submit I want it to be sent by mail to my account. [code]$progress = array(); $progress_error = false; if(!isset($progress) || !is_array($progress) || empty($progress)) {         $progress_error = true;         $error = true;     } if(!$error) { $mailBody .= "Rate your progress:\n";         if(isset($progress['A'])) $mailBody .= "- A\n";         if(isset($progress['B'])) $mailBody .= "- B\n";         if(isset($progress['C'])) $mailBody .= "- C\n";         if(isset($progress['D'])) $mailBody .= "- D\n"; <INPUT TYPE="radio" NAME="progress" value="A" <?echo isset($progress['A']) ? 'checked' : ''; ?>>&nbsp;A <br> <INPUT TYPE="radio" NAME="progress" value="B" <? echo isset($progress['B']) ? 'checked' : ''; ?>>&nbsp;B<br> <INPUT TYPE="radio" NAME="progress" value="C" <? echo isset($progress['C']) ? 'checked' : ''; ?>>&nbsp;C<br> <INPUT TYPE="radio" NAME="progress" value="D" <? echo isset($progress['D']) ? 'checked' : ''; ?>>&nbsp;D<br> [/code] The problem is that all those options have the same name="progress" so an error message appears. If I give unique names to each option then it works fine but then the user can select all the options altogether A,B,C,D and I only want him to select one of these options. How can I fix it? :(
  2. [!--quoteo(post=371224:date=May 4 2006, 02:42 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 02:42 PM) [snapback]371224[/snapback][/div][div class=\'quotemain\'][!--quotec--] if(isset($need['friend'])) { $mailBody .= "- social reasons\n"; $mailBody .= "Importance:[i] $importance[0] [/i]\n\n"; } if(isset($need['sell'])) { $mailBody .= "- sale and negotiations\n"; $mailBody .= "Importance:[i] $importance[1] [/i]\n\n"; } [/quote] [code] $mailBody .= "I need english to:\n\n";         if(isset($need['friend'])) {$mailBody .= "- social reasons\n";         $mailBody .= "Importance: ".$importance[0]."\n\n";}         if(isset($need['sell'])) {$mailBody .= "- sale and negotiations\n";         $mailBody .= "Importance: ".$importance[1]."\n\n";}[/code] same thing. Already have it.
  3. why not highlight the extra code? It would make it easier to find. I believe you only added this part: $mail_to = "name@domian.com"; //To mail which is retrieved form the data base $mail_from = "name@domian.com"; //From mail $mail_subject = "Details12";//subject header /* To send HTML mail, you can set the Content-type header. */ $headers = "MIME-Version: 1.0\n"; //setting the mime version. To send the html we have to set MIME ver 1.0 ######################################################################## # IMP IF THIS CODE DOESNT WORK ADD \r\n INSTEAD OF \n IN HEADERS ####################################################################### $headers .= "Content-type: text/html; charset=iso-8859-1\n"; //for send ing the html file /* additional headers */ $headers .= "From: Ansar<name@domian.com>\n"; //headers from address //$headers .= "Cc: name@example.com\n"; //$headers .= "Bcc: name@example.com\n"; //$body=htmlentities($body); //Function to send mail mail($mail_to,$mail_subject,$mailBody,$headers); ?> I already have a function to send mail and it works correctly, the problem that I have is that the value from the combo box is not being sent. In my email I am getting this: Social reasons: Importance: Sales and negotiations: Importance: no value in the importance.
  4. [!--quoteo(post=371206:date=May 4 2006, 01:31 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 01:31 PM) [snapback]371206[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]<? $need = array(); $importance = array();     $importance[0] = $_POST["importance"];     $importance[1] = $_POST["importance1"];     $mailBody = "I need english to:\n\n";         if(isset($need['friend']))         {         $mailBody .= "- social reasons\n";         $mailBody .= "Importance: ".$importance[0]."\n\n";         }         if(isset($need['sell']))         {         $mailBody .= "- sale and negotiations\n";         $mailBody .= "Importance: ".$importance[1]."\n\n";         }                   $mail_to = "name@domian.com"; //To mail which is retrieved form the data base $mail_from = "name@domian.com"; //From mail $mail_subject = "Details12";//subject header /* To send HTML mail, you can set the Content-type header. */ $headers  = "MIME-Version: 1.0\n";  //setting the mime version. To send the html we have to set MIME ver 1.0 ######################################################################## # IMP IF THIS CODE DOESNT WORK ADD \r\n INSTEAD OF \n IN HEADERS ####################################################################### $headers .= "Content-type: text/html; charset=iso-8859-1\n"; //for send ing the html file /* additional headers */ $headers .= "From: Ansar<name@domian.com>\n"; //headers from address //$headers .= "Cc: name@example.com\n"; //$headers .= "Bcc: name@example.com\n"; //$body=htmlentities($body); //Function to send mail mail($mail_to,$mail_subject,$mailBody,$headers);     ?>          <form action="<?=PHP_SELF?>" method="post" name="order">        <p>     <INPUT TYPE="checkbox" NAME="need[friend]" value="friend" onclick="javascript:document.order.importance.disabled=false" <? echo isset($need['friend']) ? 'checked' : ''; ?> >     &nbsp;social reasons<br>     <select disabled="true" name="importance">       <option value="0" <? echo ($importance[0] == '0' ? 'selected' : '') ?>>-</option>       <option value="1" <? echo ($importance[0] == '1' ? 'selected' : '') ?>>1</option>       <option value="2" <? echo ($importance[0] == '2' ? 'selected' : '') ?>>2</option>       <option value="3" <? echo ($importance[0] == '3' ? 'selected' : '') ?>>3</option>       <option value="4" <? echo ($importance[0] == '4' ? 'selected' : '') ?>>4</option>       <option value="5" <? echo ($importance[0] == '5' ? 'selected' : '') ?>>5</option>     </select>   </p>   <p>     <INPUT TYPE="checkbox" NAME="need[sell]" value="sell" onclick="javascript:document.order.importance1.disabled=false"<? echo isset($need['sell']) ? 'checked' : ''; ?>>     &nbsp;sales and negotiations<br>     <select name="importance1" disabled="true">       <option value="0" <? echo ($importance[1] == '0' ? 'selected' : '') ?>>-</option>       <option value="1" <? echo ($importance[1] == '1' ? 'selected' : '') ?>>1</option>       <option value="2" <? echo ($importance[1] == '2' ? 'selected' : '') ?>>2</option>       <option value="3" <? echo ($importance[1] == '3' ? 'selected' : '') ?>>3</option>       <option value="4" <? echo ($importance[1] == '4' ? 'selected' : '') ?>>4</option>       <option value="5" <? echo ($importance[1] == '5' ? 'selected' : '') ?>>5</option>     </select>     <input type="submit" name="Submit" value="Submit">   </p> </form>[/code] TRY THIS CODE [/quote] so what has changed in the code? I don't see any changes.
  5. [!--quoteo(post=371203:date=May 4 2006, 01:22 PM:name=anuka)--][div class=\'quotetop\']QUOTE(anuka @ May 4 2006, 01:22 PM) [snapback]371203[/snapback][/div][div class=\'quotemain\'][!--quotec--] let me confirm your requirement You have a form i which ther is two combo boxes and when i click submit the the selected combobx values should be send to the email . I want to ask you wheather you want to select a single value from a combo box or multiple values [/quote] correct single value. The options are 1-5. It looks like this social reasons (checkbox) importance (combo box) sales and negotiations (checkbox) importance (combo box) If I click on checkbox 1 ----> compbobox 1 is activated and I can select a value there. If I select values 1 in combobox 1 and 5 in combobox 2, in the email I should get social reasons: importance: 1 sales and negotiations: importance: 5
  6. I have a form. The user clicks on checkbox and combo box is activated. He selects the value in the combo box from 1 to 5 (which indicated importance factor) and the value is sent by email. the problem is that the value is not sent and I dont know why. Anybody knows how to fix it? [code] $need = array(); $importance = array();     $importance[0] = $_POST["importance"];     $importance[1] = $_POST["importance1"];[/code] [code] $mailBody .= "I need english to:\n\n";         if(isset($need['friend'])) {$mailBody .= "- social reasons\n";         $mailBody .= "Importance: ".$importance[0]."\n\n";}         if(isset($need['sell'])) {$mailBody .= "- sale and negotiations\n";         $mailBody .= "Importance: ".$importance[1]."\n\n";}[/code] [code] <form action="analize_rq.html" method="post" name="order"> [/code] [code] <INPUT TYPE="checkbox" NAME="need[friend]" value="friend" onclick="javascript:document.order.importance.disabled=false" <? echo isset($need['friend']) ? 'checked' : ''; ?> >&nbsp;social reasons<br> <select disabled="true" name="importance">     <option value="0" <? echo ($importance[0] == '0' ? 'selected' : '') ?>>-</option>     <option value="1" <? echo ($importance[0] == '1' ? 'selected' : '') ?>>1</option>     <option value="2" <? echo ($importance[0] == '2' ? 'selected' : '') ?>>2</option>     <option value="3" <? echo ($importance[0] == '3' ? 'selected' : '') ?>>3</option>     <option value="4" <? echo ($importance[0] == '4' ? 'selected' : '') ?>>4</option>     <option value="5" <? echo ($importance[0] == '5' ? 'selected' : '') ?>>5</option>     </select> <INPUT TYPE="checkbox" NAME="need[sell]" value="sell" onclick="javascript:document.order.importance1.disabled=false"<? echo isset($need['sell']) ? 'checked' : ''; ?>>&nbsp;sales and negotiations<br> <select name="importance1" disabled="true"> <option value="0" <? echo ($importance[1] == '0' ? 'selected' : '') ?>>-</option>     <option value="1" <? echo ($importance[1] == '1' ? 'selected' : '') ?>>1</option>     <option value="2" <? echo ($importance[1] == '2' ? 'selected' : '') ?>>2</option>     <option value="3" <? echo ($importance[1] == '3' ? 'selected' : '') ?>>3</option>     <option value="4" <? echo ($importance[1] == '4' ? 'selected' : '') ?>>4</option>     <option value="5" <? echo ($importance[1] == '5' ? 'selected' : '') ?>>5</option>     </select>[/code]
  7. [!--quoteo(post=360482:date=Mar 31 2006, 11:51 PM:name=bqallover)--][div class=\'quotetop\']QUOTE(bqallover @ Mar 31 2006, 11:51 PM) [snapback]360482[/snapback][/div][div class=\'quotemain\'][!--quotec--] What's in your <form> tag? Is its action pointing to the right file and the method set as POST? Also might be useful to check the source of the page that gets returned. That way you'd know if it's just your $_POST variables not being output, or the whole thing, or parts of it. For something like this, I'd more likely use HereDoc syntax: echo <<<END [i]... HTML with variable interpolation ...[/i] END; but it's just a matter of preference. :) [/quote] <form action="add_new.php" method="POST" name="submit">
  8. [quote]I want to gather information from the user and display it on another page. In the file commit.php I have 2 fields Product name: Description: [code] <TR><TD ALIGN="right" VALIGN="middle" width="40%"> Product name:&nbsp; </TD> <TD ALIGN="right" valign="middle"><input name="name" size="27" type="text"></TD> </TR> <TR><TD ALIGN="right" VALIGN="middle">Description:&nbsp;</TD>    <TD ALIGN="right">  <textarea name="desc" rows="5"></textarea>    </TD>    </TR> [/code] And in the file add_new.php I want to display whatever text user wrote in those two fields Product name and description. [code] <?php                      if (isset ($_POST['name']) || isset ($_POST['desc']))    {    echo'<form action="add_new.php" method="POST" name="submit">    <TR><TD ALIGN="right" VALIGN="middle" width="40%"> Product name:&nbsp; </TD> <TD ALIGN="right" valign="middle"><input name="name" size="27" type="text" value="'.$_POST['name'].'"></TD> </TR> <TR><TD ALIGN="right" VALIGN="middle">Description:&nbsp;</TD>    <TD ALIGN="right"><textarea name="desc" rows="5" value="'.$_POST['desc'].'"></textarea>    </TD>    </TR>    </form>'; } ?>   [/code] Unfortunatelly nothing is displayed althought there are no errors.[/quote]
  9. [!--quoteo(post=359273:date=Mar 28 2006, 04:00 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 28 2006, 04:00 PM) [snapback]359273[/snapback][/div][div class=\'quotemain\'][!--quotec--] When you read information from a file the resulting data includes the line terminating character(s). You need to compare against the TRIMed value: [code]<?php if (isset ($_POST['id']) && isset ($_POST['pass']))    if ($_POST['id'] != trim($lines[0]) && $_POST['pass'] != trim($lines[1]))    {     echo'form<>'; //form goes here     echo'try again'; ?>[/code] Ken [/quote] It worked fine now. Thank you. This is my 2nd day learning php so I didn't know about this. trim($lines[0]) solved the problem.
  10. I have a simple login form id and password and I want to read 2 lines from the file password.txt my code: <?php $lines=file('password.txt'); if (isset ($_POST['id']) && isset ($_POST['pass'])) { if ($_POST['id'] != $lines[0] && $_POST['pass'] != $lines[1]) { echo'form<>' ; //form goes here echo'try again'; } else { $_SESSION['id'] = "$lines[0]"; $_SESSION['pass'] = "$lines[1]"; header("Location: edit.php"); exit(); } } else { echo'form<>'; //form goes here } ?> The file password.txt has 2 lines and as a result no matter if I type in the user id and password correctly or not, I am getting try again message. What did I do wrong? If I substitute $_POST['id'] != $lines[0] by $_POST['id'] !="admin" it works fine, but I wanted to read from the file. Thanks
×
×
  • 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.