Jump to content

[SOLVED] Help with PHP code


Dwizzle

Recommended Posts

Hey EVERYone,

 

I must admit I'm am new at php, and just searching for some assistance in completing this code.  I'm trying to get this code to send a 'confirmation' back to the submitter with the contents of the form completed, something similar to a 'receipt'.  The line I'm having trouble with is the second last line in the code where it says

&& mail($email,$confirmationSubject,$confirmationBody.$body,'From: '.$to."\r\n"))

The code is listed below:

 

 

 

 

<?php

$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$name = $_POST['name']; 
$organization_name = $_POST['organization_name'];
$email = $_POST['email']; 
$subject = $_POST['subject'];
$message = $_POST['message'];

  $confirmationSubject='Technical Support';
  $confirmationBody="Hello, This email will serve as your confirmation email that we have received and will process your request in a timely mannor.  Thank you and have a fantastic day.";

$msg = " $todayis [EST] \n
Organization: $organization_name \n
Message: $message \n 
From: $name ($email)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n";

$from = "From: $email\r\n";
$todayis = date("l, F j, Y, g:i a") ;
$msg = stripcslashes($msg); 


if (eregi('http:', $message)) {
die ("<h2>I'm sorry we did not get your message please click the BACK button and try again! ! </h2>");
}
if(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))) 
{
	echo "<h2>Use the 'Back' button - Please enter a valid e-mail address!</h2>\n"; 
	$badinput = "<h2>Feedback was NOT submitted</h2>\n";
	echo $badinput;
	die ("<h1>Use the 'BACK' button above! ! </h1>");
}
if(empty($subject)) {
echo "<h2>Use the 'Back' button - Please enter a subject!</h2>\n";
die ("<h1>Use the 'BACK' button above! ! </h1>"); 
}
if(empty($name) || empty($email) || empty($message) || empty($subject)) {
echo "<h2>Use the 'Back' Button - You MUST complete all fields</h2>\n";
die ("<h1>Use the 'BACK' button above! ! </h1>"); 
}
if (mail("myemail@myemail.com", $subject, $message, $from, $organization_name)
&& mail($email,$confirmationSubject,$confirmationBody.$message,'From: 'myemail@myemail.com"\r\n"))

?>

Link to comment
Share on other sites

I actually didn't get a chance to post the error message i'm getting, so this is the error i'm getting:

 

Parse error: syntax error, unexpected T_STRING in /home/datatime/public_html/tsupport_action.php on line 196

 

The suggestion you made 'Kratsg', I tried however i believe it would actually be something different, as if it's not expecting me to using the && symbols?

 

Any other suggestions?

Link to comment
Share on other sites

if (mail("myemail@myemail.com", $subject, $message, $from, $organization_name)
&& mail($email,$confirmationSubject,$confirmationBody.$message,'From: 'myemail@myemail.com"\r\n"))

?>

 

What the heck is going on here? I think that's your missing T_STRING. You need to have the { } section of it, but I don't see it (at the bottom of the posted code)

Link to comment
Share on other sites

 

Hey 'Kratsg', i'm really not sure what you mean, however i've pasted the whole page code for your review.  Are you able to pick out something i'm doing incorrectly?  The form work correctly, it's just when i put in that one code line where it throws the error message previously stated.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">


<head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <meta name="description" content="complete solution" />
  <meta name="keywords" content="everything you need" />
  <meta name="author" content="Designs" />
  <link rel="stylesheet" type="text/css" media="screen,projection" href="./css/style_screen.css" />
  <link rel="stylesheet" type="text/css" media="print" href="./css/style_print.css" />
  <title>Technical Support</title>
  
  <script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
</head>

<body>
  <div class="page-container">

  	<!-- HEADER -->
    <!-- Global Navigation -->
    <div class="nav-global-container">
      <div class="nav-global nav-global-font">
		  <ul>
    	    <li><a href="index.html">home</a></li>
    	    <li><a href="contact.html">contact</a></li>
         	<li><a href="about.html">about us</a></li>																		
          <li><a href="#"><img class="img-flag" src="canadianflag.jpg" width="50" height="10" title="Website in English" alt="" /></a></li>
          <!--li><a href="#"><img class="img-flag" src="./img/flag_spain.gif" title="Website en Espanol" alt="" /></a></li>
          <li><a href="#"><img class="img-flag" src="./img/flag_france.gif" title ="Website en Francais" alt="" /></a></li>
          <li><a href="#"><img class="img-flag" src="./img/flag_germany.gif" title ="Website auf Deutsch" alt="" /></a></li-->					
        </ul>
	  </div>
    </div>				

    <!-- Sitename and Banner -->
	<div class="site-name">
	  Data Time Hosting
	  <div class="site-slogan">				 
			More Than Anything		  </div>
	</div>		 						
	<div><img class="img-header" src="./img/header.gif" alt="" /></div>

    <!-- Main Navigation -->												
    <div class="nav-main nav-main-font">			
		<ul>
        <li><a href="index.html">Home Page</a></li>
        <li><a href="_page.html">Hosting Page</a></li>
        <li><a href="testimonials.html">Testimonials</a></li>
        <li><a href="about.html">About Us</a></li>			
        <li><a href="contact.html"  class="selected">Contacts Us</a></li>
        <li> 
        <script language="javascript">
if (AC_FL_RunContent == 0) {
	alert("This page requires AC_RunActiveContent.js.");
} else {
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0',
		'width', '320',
		'height', '20',
		'src', '24-7',
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', 'window',
		'devicefont', 'false',
		'id', '24-7',
		'bgcolor', '#93b7db',
		'name', '24-7',
		'menu', 'true',
		'allowFullScreen', 'false',
		'allowScriptAccess','sameDomain',
		'movie', '24-7',
		'salign', ''
		); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="320" height="20" id="24-7" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="24-7.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#93b7db" />	<embed src="24-7.swf" quality="high" bgcolor="#93b7db" width="320" height="20" name="24-7" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>

        </li>
	  </ul>
</div>
	<div class="buffer"></div>

  	<!-- Sub-Navigation -->
	<div class="nav-sub nav-sub-font">
<script language="javascript">
if (AC_FL_RunContent == 0) {
	alert("This page requires AC_RunActiveContent.js.");
} else {
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0',
		'width', '160',
		'height', '500',
		'src', 'banner',
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', 'window',
		'devicefont', 'false',
		'id', 'banner',
		'bgcolor', '#ffffff',
		'name', 'banner',
		'menu', 'true',
		'allowFullScreen', 'false',
		'allowScriptAccess','sameDomain',
		'movie', 'banner',
		'salign', ''
		); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="160" height="500" id="banner" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="banner.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="banner.swf" quality="high" bgcolor="#ffffff" width="160" height="500" name="banner" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>
  
    
    </div>				

    <!-- WRAP CONTENT AND SIDEBAR -->
    <div class="container-content-sidebar">						

  		<!-- 	CONTENT -->
		<div class="content content-font">

        <!-- Page title -->		
	  	<div class="content-pagetitle">24-7 Technical Support</div>			
      
			<!-- Text container -->
			<div class="contentbox-container">
				<div class="contentbox-full">
        		<div class="contentbox-noshading">
						<p>
<?php

$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$name = $_POST['name']; 
$organization_name = $_POST['organization_name'];
$email = $_POST['email']; 
$subject = $_POST['subject'];
$message = $_POST['message'];

  $confirmationSubject='Technical Support';
  $confirmationBody="Hello, This email will serve as your confirmation email that we have received and will process your request in a timely mannor.  Thank you and have a fantastic day.";

$msg = " $todayis [EST] \n
Organization: $organization_name \n
Message: $message \n 
From: $name ($email)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n";

$from = "From: $email\r\n";
$todayis = date("l, F j, Y, g:i a") ;
$msg = stripcslashes($msg); 


if (eregi('http:', $message)) {
die ("<h2>I'm sorry we did not get your message please click the BACK button and try again! ! </h2>");
}
if(!$email == "" && (!strstr($email,"@") || !strstr($email,"."))) 
{
	echo "<h2>Use the 'Back' button - Please enter a valid e-mail address!</h2>\n"; 
	$badinput = "<h2>Feedback was NOT submitted</h2>\n";
	echo $badinput;
	die ("<h1>Use the 'BACK' button above! ! </h1>");
}
if(empty($subject)) {
echo "<h2>Use the 'Back' button - Please enter a subject!</h2>\n";
die ("<h1>Use the 'BACK' button above! ! </h1>"); 
}
if(empty($name) || empty($email) || empty($message) || empty($subject)) {
echo "<h2>Use the 'Back' Button - You MUST complete all fields</h2>\n";
die ("<h1>Use the 'BACK' button above! ! </h1>"); 
}
mail("myemail@myemail.com.com", $subject, $message, $from, $organization_name)
&& mail($email,$confirmationSubject,$confirmationBody.$body,"From: "myemail@myemail.com"\r\n"))
?>



<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $name ?> ( <?php echo $email ?> ) 
<br />
Organization: <?php echo $organization_name ?>

<br />
<?php echo $ip ?>

<br /><br />
We have received your request and will contact you shortly <font color="#CC3333">[approximately 30 minute wait]</font>. <br />
Please keep your account number handy to expidite your support request.<br />
<br /><br />
<br /><br />
<a href="plans.html"> Sign Me Up! </a> 
</p>                             
                            
                            
                            
                            
                            </p>
          	</div>
        	</div>
      	</div>        
    	</div>

    	<!-- SIDEBAR -->		
	  <div class="sidebar sidebar-font">
			<!-- Empty -->
  </div>

    <!-- END WRAP CONTENT AND SIDEBAR -->
</div>		

    <!-- FOOTER -->
    <div class="footer footer-font">
       <p><b><a href="terms.html">Terms and Conditions</a> | Copyright © 2007  | All Rights Reserved</b></p>
       <p>Design by <a href="#" target="_blank">Designs</a></p>
    </div>
  </div>
</body>
</html>

Link to comment
Share on other sites

This line

<?php
&& mail($email,$confirmationSubject,$confirmationBody.$body,"From: "myemail@myemail.com"\r\n"))
?>

 

should be written as

<?php
&& mail($email,$confirmationSubject,$confirmationBody.$body,"From: myemail@myemail.com\r\n"))
?>

 

Ken

Link to comment
Share on other sites

 

Well that's the thing i was wondering, however if i just use the line below everything works fine except no receipt, just displays the contents of what the user typed for their review:

 

mail("myemail@myemail.com.com", $subject, $message, $from, $organization_name);

 

However i would like to get an email re-sent out to the user's email address, hence why i was trying to include the second line that I'm having problems with.

 

Link to comment
Share on other sites

 

In my testing and playing around, i did try that combination as well and that didn't work for me either unfortunately.... ???

 

It's not the combination that matters.  The problem you're having is a parse error, meaning that your code doesn't make sense to php.  That's what I fixed in the code I posted.

 

Once the parse error is fixed, then you can look at fixing the logic.

 

In other words, the error you're seeing is php saying "Sorry, I can't understand your script, I'm not even going to TRY running it"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.