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 [email protected] How would I name a variable so I can have a variable inside a variable and will work? When I tried this, [email protected], 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. Link to comment https://forums.phpfreaks.com/topic/103809-how-do-you/ 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. Link to comment https://forums.phpfreaks.com/topic/103809-how-do-you/#findComment-531440 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'; Link to comment https://forums.phpfreaks.com/topic/103809-how-do-you/#findComment-531441 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? Link to comment https://forums.phpfreaks.com/topic/103809-how-do-you/#findComment-531445 Share on other sites More sharing options...
rhodesa Posted May 2, 2008 Share Posted May 2, 2008 ...need code... Link to comment https://forums.phpfreaks.com/topic/103809-how-do-you/#findComment-531455 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); ?> Link to comment https://forums.phpfreaks.com/topic/103809-how-do-you/#findComment-531462 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 = '[email protected]'; 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 Link to comment https://forums.phpfreaks.com/topic/103809-how-do-you/#findComment-531526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.