bambo123 Posted May 13, 2011 Share Posted May 13, 2011 hey guys, I am very new to PHP and wanted to create a simple form script. Somehow it doesnt work... can you help me? Help is highly appreciated!! here is the code: <?php $admin= 'name@email.com'; // 1. Message to the admin $subject1= 'You have one new subscription'; $message1.= 'Email: '.$email."\n\n"; $message1.= 'Name: '.$name."\n\n"; // Sending mail mail($admin, $subject1, $message1, "From: $email"); header('Location: http://www.youtube.com'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/ Share on other sites More sharing options...
requinix Posted May 13, 2011 Share Posted May 13, 2011 What does "doesn't work" mean? Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215122 Share on other sites More sharing options...
gizmola Posted May 13, 2011 Share Posted May 13, 2011 You have a script that sets some variables and mails them. Where is the form? Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215123 Share on other sites More sharing options...
bambo123 Posted May 13, 2011 Author Share Posted May 13, 2011 1 question: I dont receive an email at all, even though I am redirected to youtube.com... 2 question: I have a normal form and if someone clicks on the submit button this php script is started. Isn't that possible? Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215125 Share on other sites More sharing options...
fugix Posted May 13, 2011 Share Posted May 13, 2011 yes its possible, can we see your form script as well Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215126 Share on other sites More sharing options...
gizmola Posted May 13, 2011 Share Posted May 13, 2011 1 question: I dont receive an email at all, even though I am redirected to youtube.com... 2 question: I have a normal form and if someone clicks on the submit button this php script is started. Isn't that possible? mail is dependent on the local mail transfer agent program on the operating system. What OS are you running this on? You get variables from a form that uses the POST method in the $_POST[] superglobal. Read those variable values in at the top of your script. Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215165 Share on other sites More sharing options...
bambo123 Posted May 13, 2011 Author Share Posted May 13, 2011 This is the code of my form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form method="POST" action="action.php" id="form" " value="0" type="hidden"> Email:</label><input class="inputtext" id="email" name="email" value="" onkeypress="formchange()" type="text"></div><div class="form_row clearfix "><label for="pass" id="label_pass" class="login_form_label">Name:</label><input class="inputpassword" id="name" name="name" value="" type="name"></div> <label class="uiButton uiButtonConfirm uiButtonLarge" for="u261249_1"><input value="Send" name="login" onclick="" id="u261249_1" type="submit"></label> </strong></div> </form> </body> </html> For testing reasons I wanted to run my page on a server of this free webhost: http://members.000webhost.com/login.php Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215203 Share on other sites More sharing options...
rondog Posted May 13, 2011 Share Posted May 13, 2011 Not sure if this solves the issues, but before concatenating a var you need to first define it. This wont work: $message1 .= 'Email: '.$email."\n\n"; $message1 .= 'Name: '.$name."\n\n"; It has to be: Not sure if this solves the issues, but before concatenating a var you need to first define it. This wont work: $message1 = 'Email: '.$email."\n\n"; $message1 .= 'Name: '.$name."\n\n"; Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215217 Share on other sites More sharing options...
bambo123 Posted May 13, 2011 Author Share Posted May 13, 2011 Thanks for the input rondog. However, I didn't solve my primary problem... Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215220 Share on other sites More sharing options...
jcbones Posted May 14, 2011 Share Posted May 14, 2011 Most web host require your email to be sent from an account that exist on their servers. So you would need to go to your cPanel, and make an email account. Then hard code that account as the "From: $email" inside the email function. Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215248 Share on other sites More sharing options...
gizmola Posted May 14, 2011 Share Posted May 14, 2011 Thanks for the input rondog. However, I didn't solve my primary problem... Which is what? Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215252 Share on other sites More sharing options...
bambo123 Posted May 14, 2011 Author Share Posted May 14, 2011 ok, thanks jcbones, I did that. @ gizmola: My primary problem is, that I dont receive any email after executing the php script on the server. Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215284 Share on other sites More sharing options...
gizmola Posted May 14, 2011 Share Posted May 14, 2011 It's probably because either your host doesn't allow direct mails or mails at all, or your emails are being put into the spam folder, or even rejected outright. Quote Link to comment https://forums.phpfreaks.com/topic/236344-php-beginner/#findComment-1215474 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.