Jump to content

PHP Code Failing Cause Too long?!


Edward

Recommended Posts

 

Hi,

 

I have a webpage which sends a 'short list' to people, showing them the names of the actors they have selected to receive. There is a choice of about 150 actors, and for each one there is a paragraph of html which gets added to the email if the corresponding actor is selected. If I test the page on my local server it works fine and I get the email, if I view it online on my site it says it works fine but I don't receieve the email. I know the mail function does work on the site because I've tested it so all I can think is that it's timing out?? Please can someone give me a way round this or see if it could be fixed any other way. For the purpose of this post I've removed the 150 actors from the code and replaced them with one made-up actor.

<?php
ob_start();
session_start();

			if (isset($_POST['submit_send_short_list'])) {

				if (get_magic_quotes_gpc())	{
  						$email_content = stripslashes($_POST['email_content']);	// remove slashes
  					} else {
  						$email_content = $_POST['email_content'];	// remove slashes
  					}

				$subject = 'A Short List from site.co.uk';
				$body = "<html><head><style>

body
{
background: black;
}

p, div, ul, li, .white12
{
color: #FFFFFF;
font-family: Verdana, sans-serif;
font-weight: normal;
font-size: 12px;
font-style: normal;
text-decoration: none;
border: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}

a:link, a:visited, a:hover, a:active
{
color: #627572;
font-family: Verdana, sans-serif;
font-weight: bold;
font-size: 12px;
font-style: normal;
text-decoration: none;
border: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}

</style>
</head>
<body>
<table width=\"100%\" height=\"\" align=\"center\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
<tr>
<td width=\"10\" align=\"left\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"></td>
<td width=\"800\" align=\"left\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" colspan=\"3\">
<p>&nbsp<p><img src=\"http://www.site.co.uk/logo.gif\" width=\"99\" height=\"99\" alt=\"Site\" border=\"0\" /></p>
The following short list of actors has been sent to you by someone browsing site.co.uk</p>
</td>
<td width=\"10\" align=\"left\" valign=\"top\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"></td>
</tr>
".$email_content."
</table>
</body>
</html>";
				$fromname = "My Site"; // site owner
				$fromemail = "[email protected]"; // site owner
				$headers = "From: $fromname <$fromemail>\r\n"; 					//
				$headers .= "Reply-To: $fromname <$fromemail>\r\n"; 			// 2
				$headers .= "Return-Path: $fromname <$fromemail>\r\n"; 			// 3
				$headers .= "MIME-Version: 1.0\r\n";							// 4
				$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 	// 5
				$headers .= "X-Priority: 3\r\n"; 								// 4th: 1 or 3?
				$headers .= "X-MSMail-Priority: Normal\r\n"; 					// 5th: Normal or High?
				$headers .= "X-Mailer: php\r\n";
				if (mail($_POST['recipient'], $subject, $body, $headers)) {
					echo '<p>Thank you, your short list has been sent!</p>';
				}

			} else {

			echo '<p>Short List:</p>';

			if ($_GET['short_list_actor_london_john_smith'] == 'TRUE') {
				$_SESSION['short_list_actor_london_john_smith'] = 'TRUE';
			} else if ($_GET['short_list_actor_london_john_smith'] == 'FALSE') {
				$_SESSION['short_list_actor_london_john_smith'] = 'FALSE';
			}	
			if ($_SESSION['short_list_actor_london_john_smith'] == 'TRUE') {
				echo '<p>John Smith (<a href="page_02_search_left.php?short_list_actor_london_john_smith=FALSE">remove</a>)<br />
				Accent: London<br />';
				$email_content .= '<tr><td width="10" align="left" valign="top" cellpadding="0" cellspacing="0" border="0"></td><td width="120" height="170" align="center" valign="middle" cellpadding="0" cellspacing="0" border="0"><a href="http://www.site.co.uk/index2.php?page=02_search&region=london&actor=john_smith&short_list_actor_london_john_smith=TRUE"><img src="http://www.site.co.uk/page_02_search_actors/london/john_smith_small.jpg" width="120" height="160" alt="" border="0" /></a></td><td width="10" align="left" valign="top" cellpadding="0" cellspacing="0" border="0"></td><td width="650" align="left" valign="top" cellpadding="0" cellspacing="0" border="0"><p><a href="http://www.site.co.uk/index2.php?page=02_search&region=london&actor=john_smith&short_list_actor_london_john_smith=TRUE">John Smith</a><br />London</p></td><td width="10" align="left" valign="top" cellpadding="0" cellspacing="0" border="0"></td></tr>';
			}

			echo '<p><hr size="1" width="160" color="#ffffff" /></p>';

			$email_content = htmlentities($email_content, ENT_QUOTES);	// remove slashes

			echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
			echo '<p>';
			echo '<input type="text" name="recipient" value="'.$_POST['recipient'].'" size="20" maxlength="100" /><br />';
			echo '<input type="hidden" name="email_content" value="'.$email_content.'" />';
			echo '<input type="submit" name="submit_send_short_list" value="e-mail short list" />';
			echo '</p>';
			echo '</form>';

			}

ob_end_flush();
?>

 

Help would be greatly appreciated!

 

Link to comment
https://forums.phpfreaks.com/topic/58192-php-code-failing-cause-too-long/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.