firecat318 Posted May 2, 2008 Share Posted May 2, 2008 Alright, say I wanted somebody to be able to send an email, but it would be $something@blah.com How would I name a variable so I can have a variable inside a variable and will work? When I tried this, $to@somesite.com, I got a php error. I assume you need to form it in a special way so you don't get an error? Remember, $to is an input field which they fill in. Quote Link to comment Share on other sites More sharing options...
peranha Posted May 2, 2008 Share Posted May 2, 2008 can we see the error, and possibly the code you are using. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 2, 2008 Share Posted May 2, 2008 What does your code look like and what is your error. Are you doing something like this? $email = $to.'@somesite.com'; Quote Link to comment Share on other sites More sharing options...
firecat318 Posted May 2, 2008 Author Share Posted May 2, 2008 What does your code look like and what is your error. Are you doing something like this? $email = $to.'@somesite.com'; Yes, that seemed to work. But now, how come the emails aren't being sent? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 2, 2008 Share Posted May 2, 2008 ...need code... Quote Link to comment Share on other sites More sharing options...
firecat318 Posted May 2, 2008 Author Share Posted May 2, 2008 <form action=" <?php $_SERVER['PHP_SELF']; ?> " method="POST"> To: <input type="text" name="to" size="30" /><br /> From: <input type="text" name="from" size="30"><br /> Message: <input type="text" name="message" size="70" /><br /> <input type="submit" name="submit" value="submit"> </form> <?php $message = $_POST['message']; $too = $_POST['from']; $email = $too.'@gmail.com'; mail($email, $message); ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 2, 2008 Share Posted May 2, 2008 first, the syntax is: mail ( string $to , string $subject , string $message ) so it should look more like: <?php $message = $_POST['message']; $to = $_POST['from']; //Removed the extra o $email = $to.'@gmail.com'; mail($email, 'This is the subject', $message); ?> there is nothing wrong with the code above though. you can always try hard coding it first to test: <?php $message = 'This is a sample message'; $email = 'youremail@gmail.com'; mail($email, 'This is the subject', $message); ?> if you don't get that email, then contact your hosting service. if it's your server, then you probably don't have mail setup properly Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.