Jump to content

[SOLVED] Can some one check my code (is simple code)PLZ


julia

Recommended Posts

I'm a php newbee I write this code to put it in my website

and some this is wrong. I write the braquets in the if and elseif same error, without the braquets same thing. The error is at the end I'm using zend to debug.

Plz can some one help me out?

 

 

<?php

$sendername= $_POST['sendername'];

$senderlast=$_POST['senderlast'];

$company=$_POST['company'];

$ad=$_POST['ad'];

$city=$_POST['city'];

$state=$_POST['state'];

$zip=$_POST['zip'];

$zip2=$_POST['zip2'];

$country=$_POST['country'];

$email=$_POST['email'];

$email2=$_POST['email2'];

$message=$_POST['message'];

 

if($email !== $email2)

 

echo '<h1>The email address is not the same please re-enter your email address</h1>';

 

elseif($email == "")

 

echo '<h2>The email address is empty please, enter your email address</h2>';

 

elseif($sendername == "")

 

echo '<h2>The Senders Name is empty please, enter your Name </h2>';

 

elseif($senderlast == "")

 

echo '<h2>The Last Name is empty, please, enter your Last Name</h2>';

 

elseif($company == "")

 

echo '<h2>The company name is empty please, enter your company name</h2>';

 

elseif($ad == "")

 

echo '<h2>Your address is empty, please enter your address</h2>';

 

elseif($city == "")

 

echo '<h2>The city box is empty please, enter your city</h2>';

 

elseif($state == "")

 

echo '<h2>The state is not selected, please select your state</h2>';

 

elseif($zip == "")

 

echo '<h2>The zip code is empty please, enter your zipcode</h2>';

 

elseif($country == "")

 

echo '<h2>The contry is empty please, select your country</h2>';

 

elseif($message == "")

 

  echo '<h2>Message box is empty please, enter your message</h2>';

 

else

 

    echo "Your form is compleated please! press the submit buttom" ;

   

 

//Process  email form

 

$toad= '[email protected], [email protected]';

$subject= 'a message from your website';

 

$mailcontent= "Nombre de quien envia: " . "$sendername" . "$senderlast \n"; 

$mailcontent.= "Nombre de la compania: " . "$company \n ";

$mailcontent.= "direccion del que envia: " . "$ad  \n ";

$mailcontent.= "Nombre de la ciudad: " . "$city \n";

$mailcontent.= "Nombre del estado: " . "$state\n";

$mailcontent.= "Codigo postal: " . "$zip" . "$zip2 \n ";

$mailcontent.= "Nombre del pais: " . "$country \n";

$mailcontent.= 'direccion de email: ' . "$email" . "$email2 \n";

$mailcontent.= "Mensaje: \n ";

$mailcontent.= "$message";

     

$mailSent = mail("$toad", "$subject", "$mailcontent", "From: $email\r\n Reply-to:$email");

 

?>

 

 

Debug session started.

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 2 - Undefined index:  sendername

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 3 - Undefined index:  senderlast

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 4 - Undefined index:  company

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 5 - Undefined index:  ad

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 6 - Undefined index:  city

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 7 - Undefined index:  state

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 8 - Undefined index:  zip

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 9 - Undefined index:  zip2

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 10 - Undefined index:  country

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 11 - Undefined index:  email

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 12 - Undefined index:  email2

Notice: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 13 - Undefined index:  message

Debug Warning: C:\Documents and Settings\gline\My Documents\websites\julialaborde\sendform.php line 80 - mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Debug session ended.

 

Use [ code ] tags, makes it friendleir.

 

<?php
$sendername= isset($_POST['sendername'])?$_POST['sendername']:''; // do this for each of your post lines.

 

You need to check if the array has a value at the index, using the above for each of the undefined index errors will prevent the notice from coming up.

 

As for the mail error, check your smtp settings.

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.