php variable question

by coog
5 replies
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!
#php #question #variable
  • Profile picture of the author coog
    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?
    {{ DiscussionBoard.errors[1685645].message }}
  • Profile picture of the author petebolduc
    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
    {{ DiscussionBoard.errors[1687436].message }}
  • Profile picture of the author mattalways
    $yourEmail = $_POST['posSubject'];
    die("$yourEmail");

    Just to be sure you're actually getting the variable... Try that.
    Signature

    Quit wasting your money! If you need a website, get me to do it right! I'll probably even do it for less! Design/Development/Software, I'm your guy! matt@snidge.com
    {{ DiscussionBoard.errors[1694411].message }}
  • Profile picture of the author saschakimmel
    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
    Signature

    ** Get my ViralListMachine software now for free and build your own list virally by giving away free stuff @ http://www.virallistmachinegiveaway.com **

    {{ DiscussionBoard.errors[1695289].message }}
  • Profile picture of the author weaverIT
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[1699404].message }}
    • Profile picture of the author saschakimmel
      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.
      Signature

      ** Get my ViralListMachine software now for free and build your own list virally by giving away free stuff @ http://www.virallistmachinegiveaway.com **

      {{ DiscussionBoard.errors[1699893].message }}

Trending Topics