Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Notice: Undefined variable: Name

the mail() function

Moderators: macek, egami, gesf

Notice: Undefined variable: Name

Postby play007 » Sat Jul 02, 2011 8:39 pm

Hi all, i 'm a newbie in PHP. Now i want to create a popup contact us form. As below is what i done so far:-
I have a page
Code: Select all
<script  type="text/javascript" language="javascript">
$(document).ready(function(){
   $(".QTPopup").css('display','none')
   $(".lnchPopop").click(function(){
      $(".QTPopup").animate({width: 'show'}, 'slow');})
      $(".closeBtn").click(function(){
         $(".QTPopup").css('display', 'none');
      })
})
</script>
<div id="main">
     <div id="leftpanel">
                       <a href="#" class="lnchPopop">Solutions,Services & Partnerships </a><br/><br/><br/>
       </div>
<form name="form1" method="post" action="send_contact.php">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>Name</td>
<input name="Name" type="text" id="Name" style="border:0px;  background:none; margin-top:5px; width:245px;"/>
</tr>
<input type="submit" name="Submit" value="Submit" >


and i have another page which is call send_contact.php
Code: Select all
<HTML>
<HEAD>
 <TITLE>New Document</TITLE>
</HEAD>
<BODY>

  <?php

$Name ="$Name";
// Details

// Mail of sender
$mail_from="$Email";
// From
$header="from: $Name <$mail_from>";

// Enter your email address
$to ='abc@hotmail.com';

$send_contact=mail($to,$Name,$Position,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

</BODY>
</HTML>


But why i get this error "Notice: Undefined variable: Name in C:\xampp\htdocs\content\send_contact.php on line 9" ???

*p/s: actually i ignore another elements such as msg, email and etc. Coz these elements also have a same error msg like name.

any help is appreciated.
thank you.

regards,
Nasri
play007
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Jul 02, 2011 8:29 pm

Re: Notice: Undefined variable: Name

Postby jorgepinho » Wed Jul 06, 2011 2:21 pm

Hi,

Code: Select all
$Name ="$Name";


This code is bad, the second $Name doesnt exist yet, you probably need:

Code: Select all
$Name = $_POST['Name'];


but this code is very insecure, so use:

Code: Select all
$Name = htmlspecialchars($_POST['Name']);



--
Jorge
Live Help on Skype: lets.talk.about.help
(languages: english, portuguese)
jorgepinho
New php-forum User
New php-forum User
 
Posts: 101
Joined: Tue Jul 05, 2011 5:41 am
Location: Portugal


Return to PHP coding => Mail

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.