Jump to content

Recommended Posts

Hello you awesome coders.

 

I am getting a strange mesage on this site and need some help if you can to fix.

 

the site is showing this error

 

Notice: Undefined index: Submit in E:\Domains\a\aet.uk.net\user\htdocs\contact.php on line 84

 

at this page; http://aet.uk.net/contact.php

 

Can you help! the form wont post or work.

 

cheers

 

chris

 

<?php include_once("photoman/common.php");?>
<!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">
<head>
<?php include("includes/header.php"); ?>
<script language="JavaScript" type="text/javascript" src="<?php echo $pref ?>scripts/formcheck.js"></script>
</head>

<body>

<?php include("includes/banner.php"); ?>

<div id="content" class="<?php echo $sectname ?>">
 
    <?php
      $pageimage = "includes/$sectname.swf";
      if (file_exists($pageimage)) {
?>
    <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','789','height','197','title','<?php echo $sectname." page" ?>','src','includes/<?php echo $sectname ?>','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','includes/<?php echo $sectname ?>' ); //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=7,0,19,0" width="789" height="197" title="<?php echo $sectname." page" ?>">
      <param name="movie" value="includes/<?php echo $sectname ?>.swf" />
      <param name="quality" value="high" />
      <embed src="includes/<?php echo $sectname ?>.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
    </object></noscript>
<?php
        } else {  
          $pageimage = "includes/$sectname.jpg";
          $pagemax = 250;
          if (file_exists($pageimage)) {
                list($sw, $sh, $type, $attr) = getimagesize($pageimage);
                printf("<div id='pagephoto'><img src=%s alt='%s' %s></div>", $pageimage, $sectname." page image", $attr );
            } else {
            $pageimage = "includes/$sectname.gif";
              if (file_exists($pageimage)) {
                list($sw, $sh, $typwe, $attr) = getimagesize($pageimage);
                printf("<div id='pagephoto'><img src=%s %s></div>", $pageimage, $attr);
                }
            }
        }
      ?>
<?php
$submenu = getMenuXML($sectname);
if (count($submenu) > 0 ) {
?>
<ul>
<?php
    foreach ($submenu as $subitem) {
        $imagename = $subitem['image'];
        if  ($imagename == "") {
        ?>
    <li><a href="<?php echo $pref ?><?php echo $subitem['href']; ?>">
    <?php echo $subitem['name']; ?>
    </a>
    </li>
        <?php
            } else {            
        ?>
<li><a href="<?php echo $pref ?><?php echo $subitem['href']; ?>"
    onmouseover="MM_swapImage('<?php echo $imagename; ?>','','<?php echo $pref ?>images/<?php echo $subitem['rollover']; ?>',1)"
    onmouseout="MM_swapImgRestore()">
    <img src="<?php echo $pref ?>images/<?php echo ($pagename == $sectname)?$subitem['rollover']:$subitem['image']; ?>" alt="<?php echo $subitem['name']; ?>" id="<?php echo $imagename; ?>" />
    </a></li>
        <?php
            }
        
        }
    }
?>    
  <div id="pagetext">
      <?php   
      $pagefile = "includes/$filename.htm";
      if (file_exists($pagefile)) {
        $text = file_get_contents($pagefile);
        echo($text);
        } else {
      ?>
      

      <?php
      }
      ?>
<?php
if($_POST['Submit'] == "Send") {
?>
    <h2>Thank you for your interest1</h2>
    <p>We will contact you shortly.</p>
    <?php
    // send email
    $gall = new GalleryXML();
    $mailsubj = "Enquiry from ".$gall->gettitle();
    $mailto = $gall->getemail();
    $mailhead = "From: ".$_POST['email'];
    $mailbody = "Enquiry from ".$gall->gettitle()."\n";
    $mailbody = $mailbody."Name: \t".$_POST['name']."\n";
    $mailbody = $mailbody."Phone: \t".$_POST['phone']."\n";
    $mailbody = $mailbody."Email: \t".$_POST['email']."\n";
    $mailbody = $mailbody."Message: \t".$_POST['message']."\n";
        
    if ($debug) printf("Email message<br>To: %s<br>Subj: %s<br>Email body: %s<br> Header: %s<br>", $mailto, $mailsubj, $mailbody, $mailhead);
    
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    
    }
?>


<table width="50%">
<form action="<?php echo($PHP_SELF)?>" method="post" enctype="multipart/form-data" name="contactform" onSubmit="RGB_validateForm('name','','R','phone','','RisPhone','email','','RisEmail');return document.MM_returnValue">
  <tr>
    <th scope="row">Name</th>
    <td><input name="name" type="text" id="name" size="32"></td>
  </tr>
  <tr>
    <th scope="row">Telephone</th>
    <td><input name="phone" type="text" id="phone" size="24"></td>
  </tr>
  <tr>
    <th scope="row">Email</th>
    <td><input name="email" type="text" id="email" size="32"></td>
  </tr>
  <tr>
    <th scope="row">Message</th>
    <td><textarea name="message" cols="48" rows="6" id="message"></textarea>  
  </tr>
  <tr>
    <td> </td>
    <td><input type="submit" name="Submit" id="Submit" value="Send">
      <input type="reset" name="Reset" id="Reset" value="Reset">
        </tr>
</form>
</table>
  </div>

<?php include("includes/footer.php"); ?>
</body>
</html>
 

Link to comment
https://forums.phpfreaks.com/topic/288514-problem-with-contact-form/
Share on other sites

1 - please use the proper tags which are square brackets containing the word code to begin and the word /code to end



when posting code.

2 - when you have a specific error and line no.  it is nice to highlight that so that we can hone in on it.

 

That said - you have one place where 'Submit' is used as an index:

if($_POST['Submit'] == "Send") {

You apparently do not have an input element (submit button?) named 'Submit'.  What are the name= attributes of your type='submit' tags?

Edited by ginerjm
<table width="50%">
<form action="<?php echo($PHP_SELF)?>" method="post" enctype="multipart/form-data" name="contactform" onSubmit="RGB_validateForm('name','','R','phone','','RisPhone','email','','RisEmail');return document.MM_returnValue">
  <tr>
    <th scope="row">Name</th>
    <td><input name="name" type="text" id="name" size="32"></td>
  </tr>
  <tr>
    <th scope="row">Telephone</th>
    <td><input name="phone" type="text" id="phone" size="24"></td>
  </tr>
  <tr>
    <th scope="row">Email</th>
    <td><input name="email" type="text" id="email" size="32"></td>
  </tr>
  <tr>
    <th scope="row">Message</th>
    <td><textarea name="message" cols="48" rows="6" id="message"></textarea>  
  </tr>
  <tr>
    <td> </td>
    <td><input type="submit" name="Submit" id="Submit" value="Send">
      <input type="reset" name="Reset" id="Reset" value="Reset">
        </tr>
</form>

Does this mke any sense. I appologise, im not a php coder but a graphic designer, but many thanks for trying to help

Hmm.....

 

Your error message says it is coming from 'contact.php' - is that the module you expect to be running at that time?  I ask because your form has an  invalid (?) action attribute.  Did you define $PHP_SELF or did you mean to reference the PHP_SELF index of the $_SERVER array?

That says that the post array is empty.  Something is wrong with your submit - either the js validation routine is doing something to you, or the organization of the table and form tags has to be altered.  I remember having some difficulties in the past when mingling those tags.

 

Try removing the validation on your form tag and see if a plain old submit gives you anything in the post array

in your posted code (which is nothing like the actual form in an iframe at the link you posted), the form and your form processing code are on the same page and the error message about the undefined index is occurring before the form is submitted because there's no post data at that point.

 

the line of code where the error is at is testing if the form has been submitted, but it first needs to test if $_POST['Submit'] exists/isset before it can test the value in it. change the line testing if($_POST['Submit'] == "Send")  to the following to prevent the error -

if(isset$_POST['Submit'] () && $_POST['Submit'] == "Send") {

note: instead of relying on the submit button's name/value, you may want to make a hidden field in your form with name='Submit' value='Send' since not all browsers will send the submit button name/value for all possible methods of submitting the form.

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.