j05hr Posted December 31, 2008 Share Posted December 31, 2008 I had someone very kindly script a personalised contact form for me. My only problem is, in the html file if you view source on the page, it comes up with the email address that it sends too which i don't want it to do. This is the code, <form onClick="highlight(event)" name="<?php echo $formname; ?>" action="<?php print PHP_SELF ?>" method='post' enctype='multipart/form-data'> <input type='hidden' name='formmail_submit' value='Y'> <input type='hidden' name='esh_formmail_recipient' value="<?php echo $safename; echo $atsymbol; echo $safedomain; ?>"> <input type='hidden' name='esh_formmail_cc' value="<?php echo $safeccname; echo $ccemailat; echo $safeccdomain; ?>"> <input type='hidden' name='esh_formmail_return_subject' value="<?php echo $autorespondsubject; ?>"> <input type='hidden' name='esh_formmail_return_msg' value="<?php echo $autorespondmessage; ?>"> <input type='hidden' name='esh_formmail_charset' value=""> Is there a way i can stop this from showing the email address? Quote Link to comment https://forums.phpfreaks.com/topic/138996-php-contact-form-problem/ Share on other sites More sharing options...
revraz Posted December 31, 2008 Share Posted December 31, 2008 Remove the Recipient line and hardcode the address into your Mail function. Quote Link to comment https://forums.phpfreaks.com/topic/138996-php-contact-form-problem/#findComment-726920 Share on other sites More sharing options...
j05hr Posted December 31, 2008 Author Share Posted December 31, 2008 Sorry what's my mail function i'm really not very good with php Quote Link to comment https://forums.phpfreaks.com/topic/138996-php-contact-form-problem/#findComment-726922 Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 Basically show the page where the email is actually sent/show more code. The mail function is what sends the actual email. Most like it is on that same page (given that PHP_SELF links to that page). Show more code and your problem can easily be solved. Quote Link to comment https://forums.phpfreaks.com/topic/138996-php-contact-form-problem/#findComment-727007 Share on other sites More sharing options...
j05hr Posted December 31, 2008 Author Share Posted December 31, 2008 ok the php/html page <?php include_once( "contact.config.php" ); $atsymbol = "@"; $safename = $emailname; $safedomain = $emaildomain; $safeccname = $ccemailname; $safeccdomain = $ccemaildomain; if (empty ($ccemailname)) { $ccemailat = ""; } else { $ccemailat = $atsymbol; } define( "BUG_REPORT", "barrym@owt200x.us" ); define( "HOST_NAME", getEnv( "HTTP_HOST" ) ); define( "PHP_SELF", getEnv( "SCRIPT_NAME" ) ); define( "ERR_MISSING", "Missing Required Field: " ); define( "ERR_EMAIL", "Invalid " ); define( "ERR_SELECT_UPLOAD", "Please Select Upload File<br>" ); error_reporting( E_ERROR | E_WARNING | E_PARSE ); $form_mail[] = array( "name" => "Name", "text" => "Name", "type" => "text", "required" => "Required" ) ; $form_mail[] = array( "name" => "esh_formmail_subject", "text" => "Subject", "type" => "text", "required" => "Required" ) ; $form_mail[] = array( "name" => "Email_Address", "text" => "Email Address", "type" => "sender's email", "required" => "Required" ) ; $form_mail[] = array( "name" => "Daytime_Telephone", "text" => "Daytime Telephone", "type" => "text", "required" => "Required" ) ; $form_mail[] = array( "name" => "Evening_Telephone", "text" => "Evening Telephone", "type" => "text", "required" => "Required" ) ; $form_mail[] = array( "name" => "Reach_Me_By", "text" => "Reach Me By", "type" => "select", "required" => "Required" ) ; $form_mail[] = array( "name" => "How_I_Found_You", "text" => "How I Found You", "type" => "text", "required" => "Required" ) ; $form_mail[] = array( "name" => "Type_of_Event", "text" => "Type of Event", "type" => "text", "required" => "" ) ; $form_mail[] = array( "name" => "Date_of_Event", "text" => "Date of Event", "type" => "text", "required" => "" ) ; $form_mail[] = array( "name" => "Budget", "text" => "Budget", "type" => "select", "required" => "" ) ; $form_mail[] = array( "name" => "Comments_or_Questions", "text" => "Comments or Questions", "type" => "textarea", "required" => "" ) ; $isHideForm = false; if( $_POST["formmail_submit"]) { $sErr = checkPass(); if( ! $sErr ){ sendFormMail( $form_mail, "") ; $isHideForm = true; $redirect = ""; if( strlen(trim($redirect)) ): header( "Location:$redirect" ); exit; endif; } } function sendFormMail( $form_mail, $sFileName = "" ) { global $_POST ; $to = $_POST["esh_formmail_recipient"]; $from = "online.submit@" . HOST_NAME ; $subject = $_POST["esh_formmail_subject"]; $sWhatToDo = $sFileName ? "mailandfile" : "" ; $cc = $_POST["esh_formmail_cc"]; $bcc = $_POST["esh_formmail_bcc"]; $charset = $_POST["esh_formmail_charset"]; for( $i = 0; $i < count( $form_mail ); $i ++ ){ $value = trim( $_POST[ $form_mail[ $i ][ "name" ] ] ); $content .= $form_mail[ $i ][ "text" ] . " \t : " . $value ."\n"; $line .= remove_newline( $value ) . "\t" ; if( strtolower("Sender's email") == strtolower($form_mail[ $i ][ "type" ]) ) { $from = $value ; } }; $content .= "\n\nIP:" . getEnv( "REMOTE_ADDR" ); switch( strtolower($sWhatToDo) ){ case "mailandfile" : mailAttachments( $to , $subject , $content, $from, $charset, $cc , $bcc ) ; if( ! appendToFile( $sFileName, $line ) ) mailReport( $content . "\n\nWrite Form Mail to File Fail." ); break; case "fileonly" : if( ! appendToFile( $sFileName, $line ) ) mailReport( $content . "\n\nWrite Form Mail to File Fail.", $from ); break; default : mailAttachments( $to , $subject , $content, $from, $charset, $cc , $bcc ) ; } mailAutoResponse( $from ) ; } function mailAutoResponse( $to ){ global $_POST ; $subject = $_POST["esh_formmail_return_subject"]; $responseMsg = $_POST["esh_formmail_return_msg"]; if( $to && $responseMsg ) mail( $to, $subject, $responseMsg, "From: " . $_POST["esh_formmail_recipient"] ); } function mailReport( $content = "", $from = "" ){ mail( BUG_REPORT, "Error@" . HOST_NAME . PHP_SELF, $content, "From:$from" ); } function remove_newline( $str = "" ){ $newliner = "<!--esh_newline-->" ; $newtaber = "<!--esh_newtaber-->" ; $str = ereg_replace( "\t", $newtaber, $str ); $str = ereg_replace( "\r\n", $newliner, $str ); return ereg_replace( "\n", $newliner, $str ); } function checkPass() { global $form_mail ; global $_POST ; global $HTTP_POST_FILES ; for( $i = 0; $i < count( $form_mail ); $i ++ ){ $type = strtolower( $form_mail[ $i ][ "type" ] ); $value = trim( $_POST[ $form_mail[ $i ][ "name" ] ] ); $required = $form_mail[ $i ][ "required" ] ; $text = stripslashes( $form_mail[ $i ][ "text" ] ); if( !strlen($value) && ( $required == "Required" ) && $type != "attachment" ) return ERR_MISSING . $text ; if( ( strlen($value) || $type == "attachment" ) && $required == "Required" ): switch( $type ){ case strtolower("Sender's Name") : break; case strtolower("Generic email"): case strtolower("Sender's email"): if( ! formIsEMail($value) ) return ERR_EMAIL . $text ; break; case "text" : break; case "textarea" : break; case "checkbox" : case "radio" : break; case "select" : break; case "attachment" : $upload_file = $HTTP_POST_FILES[ $form_mail[ $i ]["name"] ][ "tmp_name" ] ; if( ! is_uploaded_file($upload_file) ) return ERR_SELECT_UPLOAD . $text; break; case strtolower("Time(HH:MM:SS)"): break; case strtolower("Time(HH:MM)"): break; default : } endif; } return "" ; } function formSelected( $var, $val ) { echo ( $var == $val ) ? "selected" : ""; } function formChecked( $var, $val ) { echo ( $var == $val ) ? "checked" : ""; } function formIsEMail( $email ){ return ereg( "^(.+)@(.+)\\.(.+)$", $email ); } function selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" ) { $tab = "\t" ; print "<select name=\"$name\" $style>\n" ; print $tab . "<option value=''>$prompt</option>\n" ; $nLen = strlen( "$end" ) ; $prefix_zero = str_repeat( "0", $nLen ); for( $i = $start; $i <= $end ; $i ++ ){ $stri = substr( $prefix_zero . $i, strlen($prefix_zero . $i)-$nLen, $nLen ); $selected = ( $stri == $selectedValue ) ? " selected " : "" ; print $tab . "<option value=\"$stri\" $selected >$stri</option>\n" ; } print "</select>\n\n" ; } function mailAttachments( $to = "" , $subject = "" , $message = "" , $from = "barrym@owt200x.us" , $charset = "iso-8859-1", $cc = "" , $bcc = "" ){ global $HTTP_POST_FILES ; if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ; $boundary = "====_OwT_PHP_Contact_Form_" . md5( uniqid( srand( time() ) ) ) . "===="; $headers = "From: $from\r\n"; if ($cc) $headers .= "CC: $cc\r\n"; if ($bcc) $headers .= "BCC: $bcc\r\n"; $plainHeaders = $headers ; $headers .= "MIME-Version: 1.0\nContent-type: multipart/mixed;\n\tboundary=\"$boundary\"\n"; $txtMsg = "\nThis is a multi-part message in MIME format.\n" . "\n--$boundary\n" . "Content-Type: text/plain;\n\tcharset=\"$charset\"\n\n" . $message . "\n"; $sError = "" ; $nFound = 0; foreach( $HTTP_POST_FILES as $aFile ){ $sFileName = $aFile[ "tmp_name" ] ; $sFileRealName = $aFile[ "name" ] ; if( is_file( $sFileName ) ): if( $fp = fopen( $sFileName, "rb" ) ) : $sContent = fread( $fp, filesize( $sFileName ) ); $sFName = basename( $sFileRealName ) ; $sMIME = getMIMEType( $sFName ) ; $bPlainText = ( $sMIME == "text/plain" ) ; if( $bPlainText ) : $encoding = "" ; else: $encoding = "Content-Transfer-Encoding: base64\n"; $sContent = chunk_split( base64_encode( $sContent ) ); endif; $sEncodeBody .= "\n--$boundary\n" . "Content-Type: $sMIME;\n" . "\tname=\"$sFName\"\n" . $encoding . "Content-Disposition: attachment;\n" . "\tfilename=\"$sFName\"\n\n" . $sContent . "\n" ; $nFound ++; else: $sError .= "<br>File $sFileName can not open.\n" ; endif; else: $sError .= "<br>File $sFileName doesn't exist.\n" ; endif; }; $sEncodeBody .= "\n\n--$boundary--" ; $sSource = $txtMsg . $sEncodeBody ; $nFound ? mail( $to, $subject, $sSource, $headers ) : mail( $to, $subject, $message, $plainHeaders ); return $sError ; } function getMIMEType( $sFileName = "" ) { $sFileName = strtolower( trim( $sFileName ) ); if( ! strlen( $sFileName ) ) return ""; $aMimeType = array( "txt" => "text/plain" , "pdf" => "application/pdf" , "zip" => "application/x-compressed" , "html" => "text/html" , "htm" => "text/html" , "avi" => "video/avi" , "mpg" => "video/mpeg " , "wav" => "audio/wav" , "jpg" => "image/jpeg " , "gif" => "image/gif" , "tif" => "image/tiff " , "png" => "image/x-png" , "bmp" => "image/bmp" ); $aFile = split( "\.", basename( $sFileName ) ) ; $nDiminson = count( $aFile ) ; $sExt = $aFile[ $nDiminson - 1 ] ; return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : ""; } function appendToFile( $sFileName = "", $line = "" ){ if( !$sFileName || !$line ) return 0; $hFile = fopen( "$sFileName", "a+w" ); $nBytes = 0; if( $hFile ){ $nBytes = fputs( $hFile , trim($line)."\r\n" ); fclose( $hFile ); }; return $nBytes ; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" > <link rel="stylesheet" type="text/css" href="portfolio.css" > <link rel="stylesheet" type="text/css" href="css4.css" > <link rel="stylesheet" type="text/css" href="contact.css" > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" > <title>Contact</title> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" > <style type="text/css"> <!-- .style30 {color: #FFFFFF} --> </style> <script type="text/javascript" src="contact.js"></script> <!--[if IE]> <style type="text/css" media="screen"> #menu ul li {float: left; width: 100%;} </style> <![endif]--> <!--[if lt IE 7]> <style type="text/css" media="screen"> body { behavior: url(csshover.htc); font-size: 100%; } #menu ul li {float: left; width: 100%;} #menu ul li a {height: 1%;} </style> <![endif]--> </head> <body id="contact"> <div class="header"></div> <div class="logo"><img src="logo.jpg" alt="Logo" width="200" height="100" ></div> <div class="bar1"><img src="header.jpg" alt="header" width="799" height="100"></div> <div class="left_column" style="text-align:center"> <div id="menu"> <ul id="navlist"> <li><a href="index.html" title="Link to Homepage">Home</a> <ul> <li><a href="about.html" title="Link to About Page" >About</a></li> <li><a href="portfolio.html" title="Link to Portfolio Page">Portfolio</a> <ul> <li><a href="fashion.html" title="Link to Fashion Page">Fashion</a></li> <li><a href="portrait.html" title="Link to Portrait Page">Portrait</a></li> <li><a href="reportage.html" title="Link to Reoportage Page">Reportage</a></li> <li><a href="travel.html" title="Link to Travel Page" >Travel</a></li> </ul> </li> <li><a href="contact1.php" title="Link to contact page" id="connav">Contact</a></li> </ul> </li> </ul> </div> </div> <div class="about"> <fieldset> <legend>Contact Details</legend> <form onClick="highlight(event)" name="<?php echo $formname; ?>" action="<?php print PHP_SELF ?>" method='post' enctype='multipart/form-data'> <input type='hidden' name='formmail_submit' value='Y'> <input type='hidden' name='esh_formmail_recipient' value="<?php echo $safename; echo $atsymbol; echo $safedomain; ?>"> <input type='hidden' name='esh_formmail_cc' value="<?php echo $safeccname; echo $ccemailat; echo $safeccdomain; ?>"> <input type='hidden' name='esh_formmail_return_subject' value="<?php echo $autorespondsubject; ?>"> <input type='hidden' name='esh_formmail_return_msg' value="<?php echo $autorespondmessage; ?>"> <input type='hidden' name='esh_formmail_charset' value=""> <center><img src="required.gif" alt="required" width="12" height="12"> <font color="#FFFFFF">Denotes Required Field<br></font></center> <?php if( !$isHideForm ): global $sErr ; if( $sErr ) print "<a name='error'></a><center><font class='form_error' >$sErr</font></center>"; $starColor = $sErr ? "#ff0000" : "#000000"; $style=" class='form_text' "; ?> <li> <label for="name" class="style30">Name: <img src="required.gif" alt="required" width="12" height="12"></label> <input name="Name" onBlur="stripHTML(<?php echo $formname; ?>.Name)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Name" ] ); ?>"> </li> <li> <label for="subject" class="style30">Subject: <img src="required.gif" alt="required" width="12" height="12"></label> <input name="esh_formmail_subject" onBlur="stripHTML(<?php echo $formname; ?>.esh_formmail_subject)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "esh_formmail_subject" ] ); ?>" > </li> <li> <label for="email" class="style30">Email Address: <img src="required.gif" alt="required" width="12" height="12"></label> <input name="Email_Address" onBlur="stripHTML(<?php echo $formname; ?>.Email_Address)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "Email_Address" ] ); ?>" > </li> <li> <label for="phone" class="style30">Daytime Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label> <input name="Daytime_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Daytime_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Daytime_Telephone" ] ); ?>" > </li> <li> <label for="email" class="style30">Evening Phone Number: <img src="required.gif" alt="required" width="12" height="12"></label> <input name="Evening_Telephone" onBlur="stripHTML(<?php echo $formname; ?>.Evening_Telephone)" type="text" size="25" maxlength="12" value="<?php print HtmlSpecialChars( $_POST[ "Evening_Telephone" ] ); ?>" > </li> <li> <label for="email" class="style30">Best way to reach you: <img src="required.gif" alt="required" width="12" height="12"></label> <select name="Reach_Me_By"> <option value="Email" selected="Selected" <?php formSelected( $_POST[ "Reach_Me_By" ], "Email" ); ?>>E-mail</option> <option value="Daytime Telephone" <?php formSelected( $_POST[ "Reach_Me_By" ], "Daytime Telephone" ); ?>>Daytime Telephone</option> <option value="Evening Telephone" <?php formSelected( $_POST[ "Reach_Me_By" ], "Evening Telephone" ); ?>>Evening Telephone</option> </select> </li> <li> <label for="email"><span class="style30">How did you find me: <img src="required.gif" alt="required" width="12" height="12"></span></label> <input name="How_I_Found_You" onBlur="stripHTML(<?php echo $formname; ?>.How_I_Found_You)" type="text" size="25" maxlength="50" value="<?php print HtmlSpecialChars( $_POST[ "How_I_Found_You" ] ); ?>" > </li> <li> <label for="email" class="style30">Type of event:</label> <input name="Type_of_Event" onBlur="stripHTML(<?php echo $formname; ?>.Type_of_Event)" type="text" size="25" maxlength="30" value="<?php print HtmlSpecialChars( $_POST[ "Type_of_Event" ] ); ?>" > </li> <li> <label for="email" class="style30">Date of event:</label> <input name="Date_of_Event" OnClick="javascript:showCal('Calendar')" onBlur="stripHTML(<?php echo $formname; ?>.Date_of_Event)" type="text" size="25" maxlength="20" value="<?php print HtmlSpecialChars( $_POST[ "Date_of_Event" ] ); ?>" > </li> <li> <label for="email" class="style30">Budget:</label> <select name="Budget"> <option value="£100 - £300" selected="Selected" <?php formSelected( $_POST[ "Budget" ], "£100 - £300" ); ?>>£100 - £300</option> <option value="£300 - £500" <?php formSelected( $_POST[ "Budget" ], "£300 - £500" ); ?>>£300 - £500</option> <option value="£500 - £700" <?php formSelected( $_POST[ "Budget" ], "£500 - £700" ); ?>>£500 - £700</option> <option value="£700 - £900" <?php formSelected( $_POST[ "Budget" ], "£700 - £900" ); ?>>£700 - £900</option> <option value="£900 - £1100" <?php formSelected( $_POST[ "Budget" ], "£900 - £1100" ); ?>>£900 - £1100</option> <option value="£1100+" <?php formSelected( $_POST[ "Budget" ], "£1100+" ); ?>>£1100+</option> </select> </li> <li> <label for="email"><span class="style30">Comments or Questions:</span>ns:</label> <textarea name="Comments_or_Questions" onBlur="stripHTML(<?php echo $formname; ?>.Comments_or_Questions)" cols="25" rows="3"><?php print HtmlSpecialChars( $_POST[ "Comments_or_Questions" ] ); ?></textarea> </li> <li> <div align="center"> <input type="submit" name="Submit" value="Submit" > </div> </li> </fieldset> <?php if( $sErr ) print "<script language='javascript' type='text/javascript'>location.href='#error';</script>";;; else: print( "<br><br><center><b>$thankyoumessage</b></center>" ); endif; ?> </div> <span class="style1 style22"><strong></strong><strong></strong><strong></strong></span><span class="style1 style22"><span class="style6"><strong> <div class="quotes"></div> <div class="bar"></div> <div class="flash"><object data="banner1.swf" type="application/x-shockwave-flash" width="999" height="100"> <param name="MOVIE" value="banner1.swf"> </object></div> <div class="footer"> <div align="right"></div> </div> </strong></span></span> </body> </html> and then the configuration page <?php //Email Name $emailname = "contact"; // DO NOT PUT THE @, It includes itself //Email Domain $emaildomain = "jasongold.org"; // PUT THE .COM or Other //Carbon Copy Email Name - Leave blank to disable $ccemailname = "j05hr"; // DO NOT PUT THE @ after email name, It includes itself leave blank to disable. //Carbon Copy Email Domain - Leave blank to disable $ccemaildomain = "hotmail.com"; // PUT THE .COM or Other. Leave blank to disable. //Thank You Message - Automatically set to center in the page, Don't use quotes $thankyoumessage = "<font color=#FFFFFF> <type=Arial> Your message has been sent. Thank you.</font>"; //Autoresponder Subject - Leave blank to disable, Don't use quotes $autorespondsubject = "Thank you for contacting us"; //Autoresponder Message - Leave blank to disable, Don't use quotes //Make sure do not use quotes for font prefference, use for quotes in your message $autorespondmessage = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please visit our website at www.jasongold.org"; //Form Name $formname = "contactme"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/138996-php-contact-form-problem/#findComment-727041 Share on other sites More sharing options...
revraz Posted December 31, 2008 Share Posted December 31, 2008 Should be able to just change $to = $_POST["esh_formmail_recipient"]; and make it your email address. Then remove it from your form. Quote Link to comment https://forums.phpfreaks.com/topic/138996-php-contact-form-problem/#findComment-727043 Share on other sites More sharing options...
j05hr Posted December 31, 2008 Author Share Posted December 31, 2008 So make the ["esh_formmail_recipient"] my email address? and then remove it from where? Quote Link to comment https://forums.phpfreaks.com/topic/138996-php-contact-form-problem/#findComment-727086 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.