Friday, 17 July 2015

Contact Us php script check


code attached below. have several text boxes on contact page on site (on local environment not on server yet) every time click submit button shows me code on next page. ideas might doing wrong or because it's not on server yet (<-- never had issue before on local).

form script
code:
<?php  if(!$_post) exit;  $email = $_post['email'];   //$error[] = preg_match('/\b[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}\b/i', $_post['email']) ? '' : 'invalid email address'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){ 	$error.="invalid email address entered"; 	$errors=1; } if($errors==1) echo $error; else{ 	$values = array ('name','email','message'); 	$required = array('name','email','message'); 	  	$your_email = "info@mysite.com"; 	$email_subject = "new message: ".$_post['subject']; 	$email_content = "new message:\n"; 	 	foreach($values $key => $value){ 	  if(in_array($value,$required)){ 		if ($key != 'subject' && $key != 'company') { 		  if( empty($_post[$value]) ) { echo 'please fill in required fields'; exit; } 		} 		$email_content .= $value.': '.$_post[$value]."\n"; 	  } 	} 	  	if(@mail($your_email,$email_subject,$email_content)) { 		echo 'message sent!';  	} else { 		echo 'error!'; 	} } ?>

html code on site:
code:
<form action="contact.php" method="post" id="contactform" name="redirect" value="thankyou.html" />               <table width="97%">                 <tr>                   <td width="145" align="left" valign="top" class="body" id="company"><strong>company:</strong></td>                   <td width="280" align="left" valign="top"><input name="company" type="text" size="30" /></td>                 </tr>                 <tr>                   <td align="left" valign="top" class="body" id="contact"><strong>full name:</strong></td>                   <td align="left" valign="top"><input name="name" type="text" size="30" /></td>                 </tr>                 <tr>                   <td align="left" valign="top" class="body" id="address"><strong>address: </strong></td>                   <td align="left" valign="top"><input name="address" type="text" size="30" /></td>                 </tr>                 <tr>                   <td align="left" valign="top" class="body" id="phone"><strong> phone: </strong></td>                   <td align="left" valign="top"><input name="phone" type="text" size="30" /></td>                 </tr>                 <tr>                   <td align="left" valign="top" class="body" id="email"><strong> email: </strong></td>                   <td align="left" valign="top"><input name="email" type="text" size="30" /></td>                 </tr>                 <tr>                   <td align="left" valign="top" class="body" id="comments"><strong> questions / comments: </strong></td>                   <td align="left" valign="top"><textarea name="comments" cols="25" rows="6"></textarea></td>                 </tr>                 <tr>                   <td></td>                   <td><input type="submit" name="submit" class="button" value="submit" /></td>                 </tr>               </table>             </form>
 

if you're seeing php code on submit, there's wrong local server's configuration , it's not parsing script. it's outputting text.

side note, eregi has been deprecated of php 5.3.0. relying on feature highly discouraged.
 


Forums Special Interests Web Design and Development


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment