rayames1
rayames1

Reputation: 11

Concatenation email recipient address

This is a form that I get the user to enter data including their mobile number and mobile carrier. I am using concatenation of the mobile number and carrier to send a message to their phone. This works but I am having a problem with the concatenation for the email recipient. If I use a straight email address ("[email protected]"), it will deliver the content. It will not work using the concatenation of $phone and $carrier ($YourEmailAddress). I have tried several different methods but nothing is working. I have tried using "&" and "+". I need assistance in figuring out why the concatenation of the phone and carrier strings is not working. I am new to this site so I am not sure if I correctly posted this.

This is my php file:

 <?php
if( count($_POST) )
{
   $YourEmailSubject = "Form Submission From the Blog";
   $name = stripslashes($_POST['name']);
   $email = stripslashes($_POST['email']);
   $comment = stripslashes($_POST['comment']);
   $phone = ($_POST['phone']);
   $selectOption = $_POST['carrier'];
   $content = "$name\r\n$email\r\n$comment\r\n$selectOption\r\n";
   $YourEmailAddress = $phone."@".$selectOption;
   mail($YourEmailAddress,$YourEmailSubject,$content,"From: ABC Company");
   header("Location:" . (isset($_POST['redirect']) ? $_POST['redirect'] : '/') );
   exit;
}
?>

This is my form:

    <form method="post" action="/simplecontact.php">
<input type="hidden" name="redirect" value="//www.google.com">
<p>
Name:<br>
<input type="text" name="name" style="width:200px;"></td>
</p>
<p>
Email:<br>
<input type="text" name="email" style="width:200px;"></td>
</p>
<p>
Comment:<br>
<textarea name="comment" style="width:200px; height:100px"></textarea></td>
</p>
<p>Phone Number:<br> 
<input type="text" id="number" name="number" /></td>
</p>

            Carrier: <br>

                <select id="carrier" name="carrier">
                    <option value="tmomail.net">T-mobile</option>
                    <option value="vmobl.com">Virgin Mobile</option>
                    <option value="cingularme.com">Cingular</option>
                    <option value="messaging.sprintpcs.com">Sprint</option>
                    <option value="txt.att.net">AT&amp;T</option>
                    <option value="vtext.com">Verizon</option>
                    <option value="messaging.nextel.com">Nextel</option>
                    <option value="email.uscc.net">US Cellular</option>
                    <option value="sms.mycricket.com">Cricket</option>
                    <option value="mymetropcs.com">Metro PCS</option>
                    <option value="myboostmobile.com">Boost Mobile</option>

                </select>
<p>
<input type="submit" style="width:200px;" value="Submit Form"></td>
</p>
</form>

Upvotes: 0

Views: 160

Answers (1)

alexpereap
alexpereap

Reputation: 180

In your form the phone input name is "number", in the php code you are trying to get the phone number like the input name was "phone"

Just change the input name to "phone"

<input type="text" id="number" name="phone" /></td>

Upvotes: 1

Related Questions