Jump to content


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


Can anyone help.

Recommended Posts

I've fixed my previous problem and i have been confronted with another one.

the script i've written displays some flash movies along side an enquiry form, and when you enter all the details and press the submit button it sends the details where there supposed to go and then display the appropiate thank you message, but it also display the entire form again and the flash movies which i dont want it to do. 

As i've only been messing around with php for about 2 months now, i'm a little unsure what to do. An ideal solution would be have the program load a specific page depending on what has occured. (ie. one page if there was an error and one whenh everything is ok) i'm pretty sure that this can be done and i'm positive that some where, someone has the knowlegede.

i have attached one of the forms (there are 8 in total on the site, but they are all identical except for the flash movies) in the hope that one of you can help me figure this one out.

i eagerly await a reply.

[attachment deleted by admin]

Share this post

Link to post
Share on other sites
Without looking at the code, how does it know to display the thankyou message? If you have enough details about the user's actions to do that, surely you can suppress the form and any other items as well.

There will be better ways but what I mean is, where the thankyou message goes, set a boolean to true and only add items that you don't want if it is false.

Hard to tell if that helps. Can't download files at work.


Share this post

Link to post
Share on other sites
i belive
if ($_POST['forums_submit_buttons_name'])
// forum has been subminited, so prosses it.
// display forum, as it hasnt been submited.

is what you are looking for.

Share this post

Link to post
Share on other sites
heres the code :

// 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/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- 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 {
height: 33px;
width: 287px;

<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 to run flash objects properly -->
        <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<div id="wrapper">
<!-- display flash movie of concept cover -->
<div align="center">
  <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','132','height','132','align','middle','src','flash/blues','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','flash/blues' ); //end AC code
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=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.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>

<!-- 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>
<div align="center">
<?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>
<div align="center">
<?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 } ?>
    <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">
    <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 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 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 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 colspan="2" align="left" valign="top">
<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>
<br />
<!-- display 'submit' button -->
<input Name="pcdComments" type="submit" id="pcdComments" value="Submit Enquiry" />

<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.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0','width','145','height','32','align','bottom','src','streaming/blues-f','quality','best','wmode','transparent','bgcolor','#FFFFFF','loop','true','pluginspage','http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash','movie','streaming/blues-f' ); //end AC code
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=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.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" align="bottom"></embed>

what happens is this :-

when the form is first displayed, theres a small flash movie and a streaming flash music player that starts automatically playing.  after the user has entered their information and it has been submitted then a message saying thank you is displayed or if there's an error then an error message is displayed BUT!, the form and the flash movies are also displayed again.  wheat i would like if for only the thank you message to be displayed along with a "click here to continue" style link to another page.

please forgive me if this makes no sense, i'm trying my best to explain things.

Share this post

Link to post
Share on other sites


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.