koolio Posted December 12, 2006 Share Posted December 12, 2006 Totally new to php, I basically got this simple script (free) which is like a feedback form, and im wondering after i add my e-mail into the script, do i put the php in a special folder on my server, because as of now the script works, it says "thank you for your feedback" but i dont get the mail. Thnx Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/ Share on other sites More sharing options...
timmah1 Posted December 12, 2006 Share Posted December 12, 2006 show your script, and we might be able to help Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/#findComment-139681 Share on other sites More sharing options...
koolio Posted December 12, 2006 Author Share Posted December 12, 2006 [code]$notify_injections = true; //set to false if you don't want to e-mail yourself //with notifications of e-mail injection attempts$mail_target = '[email protected]'; //specify your e-mail address here$mail = array('sender' => @$_POST['sender'], //retrieve POSTed form field data - should match the 'sender_name' => @$_POST['sender_name'], //names of the various fields in the <FORM> below 'subject' => @$_POST['subject']);$mail_message = @$_POST['message'];function validate_mail($field, $mail_header) {// $mail_header = "a\rBcc:spoof1\rTo:spoof2"; //used for testing the validate_mail function; see docs $alert = ''; if (@preg_match_all("/(\r|\n)([^:]+):/", $mail_header, $m)) foreach($m[0] as $v) $alert .= '<span style="width:100px;font:bold">'.$field.'</span>'.$v.'<br>'; //check for invalid header data return $alert;}echo '<style>h1 { font:bold 14pt verdana }.alert { font:bold;color:red }.form_table { border:0;text-align:left;font:bold 8pt Verdana;line-height:24px;width:400px;padding:4px }.short_input { height:24px;width:190px;font:8pt Verdana;padding:4px }.long_input { height:24px;width:400px;font:8pt Verdana;padding:4px }.message_box { width:400px;font:8pt Verdana;padding:4px }.submit { font:8pt Verdana;padding:2px }</style><h1>Contact Us</h1><p>';$show_form = true; //by default, show the HTML <FORM>if ($mail_message != '') { //if a message has been left, do the following: $alert = ''; foreach ($mail as $k => $v) $alert .= validate_mail($k, $v); //validate each mail header if ($alert != '') { if ($notify_injections == true) $mail_result = @mail($mail_target, 'E-mail insertion attack', '<html><body>E-mail injection attempted via header insertion<p><span style="width:100px;font:bold">Remote IP</span>'.@$_SERVER['REMOTE_ADDR'].'<br><span style="width:100px;font:bold">Remote Host</span>'.@$_SERVER['REMOTE_HOST'].'<p><span style="width:100px;text-decoration:underline">form-field</span><u>injected header</u><br>'.$alert.'</body></html>'); if ($mail_result == 1) { //thank them for their submission - you don't want to let echo 'Your comments have been submitted. Thank you.'; //them know you're aware of their attack, do you? $show_form = false; //and after submission, you need not re-display the form } else echo 'Unknown error: mail not sent. Please try again.'; } else if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i", $mail['sender'])) echo '<span class="alert">* A valid e-mail address is required for your comments to be registered *</span>'; //validate e-mail address - described in accompanying docs else if ($mail['sender'] == '' or $mail['sender_name'] == '') echo '<span class="alert">* You must enter your comments and a name and e-mail address for your comments to be registered *</span>'; else { $mail_result = @mail($mail_target, $mail['subject'], $mail_message, "From: $mail[sender_name] ($mail[sender])"); if ($mail_result == 1) { //mail function here works as above echo 'Your comments have been submitted. Thank you.'; $show_form = false; } else echo 'Unknown error: mail not sent. Please try again.'; }}else echo 'Please send us your question or comments:';if ($show_form == true) echo '<p><form action="'.$_SERVER['PHP_SELF'].'" method="post"><table class="form_table"><tr><td style="padding:0 15px 0 0">Name:<br><input name="sender_name" type="text" maxlength="50" value="'.$mail['sender_name'].'" class="short_input"></td><td>E-mail Address:<br><input name="sender" type="text" maxlength="50" value="'.@$mail['sender'].'" class="short_input"></td></tr><tr><td colspan=2><p>Subject:<br><input name="subject" type="text" maxlength="50" value="'.@$mail['subject'].'" class="long_input"><p>Comments:<br><textarea name="message" rows="30" class="message_box">'.@$mail_message.'</textarea><p><input type="submit" name="submit" value="Submit" class="submit"></td></tr></table></form>';?>[/code] Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/#findComment-139686 Share on other sites More sharing options...
timmah1 Posted December 12, 2006 Share Posted December 12, 2006 That script works fine.Save that script like something like, contact.php, and upload it to your server.when I tested it, it worked without a problem Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/#findComment-139689 Share on other sites More sharing options...
koolio Posted December 12, 2006 Author Share Posted December 12, 2006 Ya i was pretty sure its not the script, im just wondering where do i put this script on my server, can it be in any folder or what? Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/#findComment-139710 Share on other sites More sharing options...
wattsup88 Posted December 12, 2006 Share Posted December 12, 2006 It depens on the server... my server i can put it anywhere... do you even have php installed for sure on your server? Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/#findComment-139714 Share on other sites More sharing options...
timmah1 Posted December 12, 2006 Share Posted December 12, 2006 [quote author=koolio link=topic=118313.msg483371#msg483371 date=1165941270]Ya i was pretty sure its not the script, im just wondering where do i put this script on my server, can it be in any folder or what?[/quote]Who are you hosting with?Check their FAQ and it should tell you.I've never run into a problem with where to put a PHP file, either on a Linux or Windows server. Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/#findComment-139722 Share on other sites More sharing options...
koolio Posted December 12, 2006 Author Share Posted December 12, 2006 ill check it out, but i know they are running linux with php 4.4.4 or somethin. thnx 4 ur help Link to comment https://forums.phpfreaks.com/topic/30358-warning-im-a-newbie/#findComment-139724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.