email form/global_register OFF

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jarow
Forum Commoner
Posts: 83
Joined: Tue Jan 28, 2003 2:58 am

email form/global_register OFF

Post by jarow »

This simple form works fine with global_registers ON but with globals OFF it does not. Can anyone give me an idea how I can get this to work with globals OFF. many thanks

Code: Select all

<?php

$fname = "James";           // Name to be shown in from details.
$femail = "address@hotmail.com";  // E-mail address to be shown in  from details.

//-------------------------------------------------------------------------------------------

if(!isset($action)){

?>


<form name="form1" method="post" action="mailform.php">
<input name="action" type="hidden" value="send">
<table width="370" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td width="120" >to e-mail:</td>
    <td width="250" ><input name="toemail" type="text" size="30"></td>
  </tr>

  <tr>
    <td>subject:</td>
    <td><input name="subject" type="text" size="30" value=""></td>
  </tr>
  <tr>
    <td  valign="top">message:</td>
    <td>
	 <textarea name="message" rows="5" cols="35">

	 </textarea>
	</td>
  </tr>
  <tr>
    <td>type:</td>
    <td>
	  text&nbsp;<input name="rdType" type="radio" value="0" checked>
	  &nbsp;&nbsp;
	  html&nbsp;<input name="rdType" type="radio" value="1">
	</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
	 <input name="cmdSend" type="submit" value="send">&nbsp;
	 <input name="cmdReset" type="reset" value="reset">
	</td>
  </tr>
</table>
</form>


<?php
}else{
 $from = $fname . "<$femail>";
 $headers = "From: $from \r\n";
 if($rdType == 1){
   $headers .= "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1";
   $message = stripslashes($message);
 }else{
   $headers .= "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=iso-8859-1";
 }
 $ok = @mail($toemail, $subject, $message, $headers);
  if ($ok) {
   echo "<center><font class='general'>Mail sent successfully. Thank you.</font></center>";
  } else {
   echo "<center><font class='general'>Mail could not be sent.</font></center>";
  }
 }

?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

a real quick dirty way to do it would be to put this line at the top of your script

Code: Select all

extract($_POST);
Mark
User avatar
phpcoder
Forum Contributor
Posts: 158
Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK

Post by phpcoder »

or use $_POST['varname'] with every variable
jarow
Forum Commoner
Posts: 83
Joined: Tue Jan 28, 2003 2:58 am

Post by jarow »

Thanks very much to all who answered. I turned out that sendmail_from was incorrectly set up on the server.

All fixed.

thanks again
Post Reply