Jump to content


Photo

Can anyone help.


  • Please log in to reply
5 replies to this topic

#1 case

case
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 20 July 2006 - 07:45 PM

i have a working feedback script, but what i would like todo is for it to load a thank you page when the form has been submitted and an eror page when its gone wrong.

heres the code from the rror check section:

<?php if (isset($error['notSent'])) { ?>
    <h1 align="center" class="style2">Server Error</h1>
    <p align="center" class="warning"><?php echo $error['notSent']; ?></p>
<div align="center">
<?php } elseif ($mailSent) { ?>
    </div>
<h1 align="center" class="style2">Enquiry submitted.</h1>
<p align="center" class="style2">We appreciate your interest and will be in touch soon.</p>
<div align="center">
<?php } else { ?>
  </div>

anyone got any ideas ?

#2 ChaosXero

ChaosXero
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts

Posted 20 July 2006 - 07:47 PM

What error is it giving you or what is it not doing that it should?

#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 20 July 2006 - 07:50 PM

<?php } else { ?>

Is there anything that comes after this?? If not, remove the else clause.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#4 case

case
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 21 July 2006 - 03:22 AM

here's the entire listing:-

<?php
// set flag to indicate weather the mail has been sent
$mailSent = false;
if (array_key_exists('pcdComments', $_POST)) {
// mail processing script
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
}

  // validate the input, beginning with name
  $name = trim($_POST['name']);
  if (empty($name)) {
    $error['name'] = 'Please enter your name';
    }

// check for valid email address
$email = $_POST['email'];
$pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
if (!preg_match($pattern, trim($email))) {
$error['email'] = 'Please enter a valid email address';

// check the content of the text area
$messageBody = trim($_POST['message']);

// init. varibles
$to = 'info@planetcd.biz' ; // set email address
$subject = 'Enquiry re: Blues Music'; // set subject

// build the message
$message = 'On '.date('l, M j, Y').' at '.date('g:ia').', ';
$message .= "$name ($email) from $company ($position) wrote: \n\n";
$message .= $messageBody;

// send the email
$additionalHeaders = "From: Planet CD<info@planetcd.biz>\r\n";
$additionalHeaders .= "Reply-To: $email";

// send the mail if theres no errors
if (!isset($error)) {
$mailSent = mail($to, $subject, $message, $additionalHeaders);
// check the mail was sent successfully
if (!$mailSent) {
$error['notSent'] = 'Sorry, there was a problem sending you enquiry. Please try later.';
}
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!-- define meta tags -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<!-- page header -->
<title>PlanerCD Online Enquiry Form</title>

<!-- define styles used for text and 'floating media player' -->
<style type="text/css">
.style2 {
font-family: eurostile;
font-size: 16px;
font-weight: bold;
color: #9966CC;
text-decoration: none;
font-style: normal;
line-height: normal;
font-variant: normal;
text-transform: none;
text-align: left;
}
#onmyown {
position:absolute;
top:385px;
left:178px;
z-index:10;
height: 33px;
width: 287px;
}
</style>

<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.Name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>

<!-- script to run flash objects properly -->
        <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>
<div id="wrapper">
<!-- display flash movie of concept cover -->
<div align="center">
  <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macr...vie,flash/blues' ); //end AC code
    </script>
  <noscript>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macr...rsion=7,0,19,0" width="132" height="132" align="middle">
      <param Name="movie" value="flash/blues.swf" />
      <param Name="quality" value="high" />
      <embed src="flash/blues.swf" width="132" height="132" align="middle" quality="high" pluginspage="http://www.macromedi...getflashplayer" type="application/x-shockwave-flash"></embed>
      </object>
      </noscript>
    </div> 

<!-- this section handles all the messages, depending on what has happened -->
<?php if (isset($error['notSent'])) { ?>
    <h1 align="center" class="style2">Server Error</h1>
    <p align="center" class="warning"><?php echo $error['notSent']; ?></p>

<?php } elseif ($mailSent) { ?>

<h1 align="center" class="style2">Enquiry submitted.</h1>
<p align="center" class="style2">We appreciate your interest and will be in touch soon.</p>

<?php } else { ?>

<p align="center" class="style2">Thanks for your enquiry regarding the Blues music, please fill out the details below &amp; we will send you an 8 track sampler CD concept - of exceptional quality - which will illustrate the calibre of product we can produce on behalf for your company/client. </p>
<div align="center">
  <?php } ?>
</div>
 
    <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="contactForm" id="contactForm" onsubmit="MM_validateForm('name','','R','email','','RisEmail','message','','R');return document.MM_returnValue">

<table width="100%" border="0">
  <tr>
    <td width="50%" align="left"><!-- Name section -->
    <label for="name" class="style2">Name:</label>
<?php if (isset($error['name'])) { ?>
    <span class="warning"><?php echo $error['name']; ?></span>
    <?php } ?>
    <input type="text" name="name" id="name"
<?php if(isset($error)) {echo "value='$name'";} ?> />
</td>
   
<td width="50%" align="left"><!-- company -->
<label for="company" class="style2">Company:</label>
<?php if (isset($error['company'])) { ?>
<span class"warning"><?php echo $error['company']; ?></span>
<?php }?>
<input type="text" Name="company" id="company"
<?php if(isset($error)) {echo "value='$company'";} ?> />
</td>
  </tr>
<tr>
<td width="50%" align="left"><!-- email address -->
    <label for="email" class="style2">Email:</label>
    <?php if (isset($error['email'])) { ?>
<span class"warning"><?php echo $error['email']; ?></span>
<?php }?>
<input type="text" Name="email" id="email"
<?php if(isset($error)) {echo "value='$email'";} ?> />
</td>

<td width="50%" align="left"><!-- position -->
<label for="position" class="style2">Position:</label>
<?php if (isset($error['position'])) { ?>
<span class"warning"><?php echo $error['position']; ?></span>
<?php }?>
<input type="text" Name="position" id="position"
<?php if(isset($error)) {echo "value='$position'";} ?> />
</td>
</tr>
<tr>

<td colspan="2" align="left" valign="top">
<!-- USER MESSAGE -->
<label for="textarea" class="style2">Additional Info/Comments/Address:</label>
<?php if (isset($error['message'])) { ?>
<span class"warning"><?php echo $error['message']; ?></span>
<?php }?>
<br />
<textarea Name="message" cols="50" rows="3" id="message"><?php if(isset($error))
{echo $messageBody;} ?></textarea>
</td>
</tr>
</table>
<br />
<!-- display 'submit' button -->
<input Name="pcdComments" type="submit" id="pcdComments" value="Submit Enquiry" />
</form>

<div id="onmyown">
  <p align="left"><img src="images/button_click2mute.jpg" alt="floating layer music player" width="136" height="21" align="bottom" />
      <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macr...reaming/blues-f' ); //end AC code
</script>
      <noscript>
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macr...ersion=4,0,0,0" width="145" height="32" align="bottom">
        <param Name="movie" value="streaming/blues-f.swf" />
        <param Name="quality" value="best" />
        <param Name="wmode" value="transparent" />
        <param Name="bgcolor" value="#FFFFFF" />
        <param Name="loop" value="true" />
        <embed src="streaming/blues-f.swf" quality="best" wmode="transparent" bgcolor="#FFFFFF" loop="True" width="145" height="32" type="application/x-shockwave-flash" pluginspage="http://www.macromedi...ShockwaveFlash" align="bottom"></embed>
      </object>
    </noscript>
  </p>
</div>
</body>
</html>

if anyone has any ideas i'd like to hear them.

#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 21 July 2006 - 03:41 AM

Posting all that DOES NOT help. This board is setup for people wanting to learn php. Not people pumping out Dreamweaver crap (in fact... we have a whole forum dedicated to that). Do you understand what your code does? There is your problem.

#6 case

case
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 22 July 2006 - 04:56 AM

nice answer, i do understand most of the code what i'm looking for is some pointers.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users