php variable question

by 5 replies
6
I'm setting up a contact form where the user chooses the person to email from a dropdown list. I can't seem to get the dropdown value to pass properly, I'm sure I'm missing something and was wondering if anyone can help:

Here's the HTML:
HTML Code:
<div class="form">What is your question related to: 
<select name="posSubject" id="posSubject">
<option value="bill" selected>General Question</option>
<option value="john">Warranty Question</option>
<option value="cory">Estimating</option>
<option value="bob">Service Question</option>
</select>
Here's the code in my mail script:
PHP Code:
$yourEmail $_POST["posSubject"] . '@mydomain.com'
It never picks up the posSubject value and the output is just @mydomain.com The select box is between the form tags, I'm using POST method, and the other fields are working fine. Any ideas?

Thanks!
#programming #php #question #variable
  • oop's guess I posted that too many times. It was weird, every time I posted the forum gave me an sql error so I went back and changed something, thinking it was the code in my post. Sorry, is there a way for me to delete my own posts?
  • Are you passing to another page or to the same page... it would help if you put the entire form up for a view.

    Thanks Pete
  • Banned
    [DELETED]
  • $yourEmail = $_POST[''];
    die("$yourEmail");

    Just to be sure you're actually getting the variable... Try that.
  • Do you actually have something like this on the page?
    <form method="post" action="...">

    If you're not setting "post" explicitly the browser will choose "get" hence you had to use $_GET instead of $_POST
  • Banned
    [DELETED]
    • [1] reply
    • Sorry to say this, but the code above may be used to send e-mails to arbitrary e-mail addresses if $contact_email=$_POST['contact'].

      Just enter "info@example.com,info2@example.com,info3@example. com,info" in the contact field and the e-mail will be sent to all four addresses.

      This could be used by spammers.

      Just change it like this:
      if($_POST['contact']){
      $to = preg_replace("/[^0-9a-zA-Z]/", "", $_POST['contact'].'@domain.com');

      This way every characters except 0-9, a-z and A-Z are stripped from the contact value given.
  • Banned
    [DELETED]

Next Topics on Trending Feed

  • 6

    I'm setting up a contact form where the user chooses the person to email from a dropdown list. I can't seem to get the dropdown value to pass properly, I'm sure I'm missing something and was wondering if anyone can help: Here's the HTML: