Jump to content

an undefined index Ooer.


rofl90

Recommended Posts

I have here two files, a form, and a validate file as follows:

 

* I can't see any problems, and I do define the variables here are the errors:

Notice: Undefined index: Name in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 5

 

Notice: Undefined index: Tel in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 6

 

Notice: Undefined index: Email in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 7

 

Notice: Undefined index: Website in e:\domains\p\prowebdesigns.co.uk\user\htdocs\send.lib.php on line 8

<?php
$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = "Contact form";
$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Website = Trim(stripslashes($_POST['Website'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Website: ";
$Body .= $Website;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">";
}
?>

and

<html>
<head>
<link href="css/content_css.css" rel="stylesheet" type="text/css">
</head>
<body class="mid-mid">

<div align="left">
<form name="frmFormMail" action="send.lib.php" method="post">
  <table cellspacing='16' cellpadding='0' border='0'  >
    <tr>
      <td width="334" align='right' valign='top' class="mid-mid">Name </td>
      <td width='18'  aligh='right' valign='top'> <span class="mid-mid"><font size='2' color='#ff0000'>*</font> </span></td>
      <td colspan="2" class="mid-mid">
          <input type="text" name="Name2">
      </td>
    </tr>
    
    <tr>
      <td class="mid-mid" valign='top' align='right'>Phone </td><td width='18'  aligh='right' valign='top'> </td>
      <td colspan="2" class="mid-mid">
          <input type="text" name="Tel2">
      </td>
    </tr>
    
    <tr>
      <td class="mid-mid" valign='top' align='right'>Email </td><td width='18'  aligh='right' valign='top'> <span class="mid-mid"><font size='2' color='#ff0000'>*</font> </span></td>
      <td colspan="2" class="mid-mid">
          <input type="text" name="Email2">
      </td>
    </tr>
    
    <tr>
      <td class="mid-mid" valign='top' width="50" align='right'>Website </td>
      <td width='18'  aligh='right' valign='top'></td>
      <td colspan="2" class="mid-mid">
        <input type="text" name="Website2">
      </td>
    </tr>    
<tr>
      <td class="mid-mid" valign='top' align='right'>Type </td><td width='18'  aligh='right' valign='top'></td>
      <td width="342" class="mid-mid">Billing:
        <br />
        Inquir:
        <br />
        Sales
        <br />
        Presales
        <br />
        Quote
        <br />
        Technical      </td>
      <td width="342" class="mid-mid">
        <input type="checkbox" name="Billing" value="Yes">
        <br />
        <input type="checkbox" name="Inquiry" value="Yes">
        <br />
        <input type="checkbox" name="Sales" value="Yes">
        <br />
        <input type="checkbox" name="Presales" value="Yes">
        <br />
        <input type="checkbox" name="Quote" value="Yes">
        <br />
        <input type="checkbox" name="Technical" value="Yes">
      </td>
</tr>
    
    <tr>
      <td class="mid-mid" valign='top' align='right'>Message </td><td width='18'  aligh='right' valign='top'> <span class="mid-mid"><font size='2' color='#ff0000'>*</font> </span></td>
      <td colspan="2" class="form_text"><span class="mid-mid">
        <textarea name="Message"></textarea>
      </span></td>
    </tr>
    <tr><td colspan=4 align='center' class="mid-mid">
      <input name="Submit" type='submit' value='Submit'>
   
<input name="Reset" type='reset' value='Cancel'>
    </td></tr>
  </table>
</form>
</span>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/90314-an-undefined-index-ooer/
Share on other sites

You can only use lowercase names when calling a function for example

Functions are case-insensitive. Ony variables are case-sensitive

 

@rofl90

Notices are not errors. I'd recommend you to change your code to:

<?php

if(isset($_POST['Submit']))
{
    $EmailFrom = "[email protected]";
    $EmailTo = "[email protected]";
    $Subject = "Contact form";
    $Name = Trim(stripslashes($_POST['Name2']));
    $Tel = Trim(stripslashes($_POST['Tel2']));
    $Email = Trim(stripslashes($_POST['Email2']));
    $Website = Trim(stripslashes($_POST['Website2']));
    $Message = Trim(stripslashes($_POST['Message']));

    // validation
    $validationOK=true;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">";
      exit;
    }

    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $Name;
    $Body .= "\n";
    $Body .= "Tel: ";
    $Body .= $Tel;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";
    $Body .= "Website: ";
    $Body .= $Website;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";

    // send email
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    // redirect to success page
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=main.php\">";
    }
}
?>

Your input fields where named as Name2, Tel2, Email2, Website2 etc rather than Name, Tel, Email, Website

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.