Page 1 of 1

email form/global_register OFF

Posted: Wed Jan 21, 2004 8:12 am
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>";
  }
 }

?>

Posted: Wed Jan 21, 2004 8:50 am
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

Posted: Wed Jan 21, 2004 2:05 pm
by phpcoder
or use $_POST['varname'] with every variable

Posted: Thu Jan 22, 2004 6:47 am
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