Jump to content

Mailing form problem


sanna

Recommended Posts

Hey guys,

 

I'm a total n00b to PHP  :shrug:, think it's quite fun, but this mailing form is driving me nuts... think I've gone blind on it. Have read so many guides on the mail function now that my eyes are going sore. And I haven't even gotten to the validation part yet! Anyone see the error, why it won't load page / send properly? :wtf:

I basically copied the stuff from w3shools and changed stuff around. The problem seems to be something in the beginning around the "mail" function (get error function not defined from Crimson Editor).

 

Many thanks, hope someone can help a poor newb  :-*

 

 

<html>

<body>

 

<?php

if (isset($_REQUEST['email']))

//if "email" is filled out, send email

  {

  //send email

  $to = '[email protected]' ;

  $email = $_REQUEST['email'] ;

  $subject = $_REQUEST['foretag'] ;

  $message = $_REQUEST['namn']\n ;

  $message .= $_REQUEST['foretag']\n ;

  $message .= $_REQUEST['hemsida']\n ;

  $message .= $_REQUEST['bransch']\n ;

  $message .= $_REQUEST['adress']\n ;

  $message .= $_REQUEST['tel']\n ;

  $message .= $_REQUEST['uppna']\n ;

  $message .= $_REQUEST['unik']\n ;

  $message .= $_REQUEST['annat']\n ;

  $message .= $_REQUEST['modig']\n ;

  $message = wordwrap($message, 70, '<br />\n');

  mail($to, "$subject",  $message, "From:" . $email);

  echo "Thank you for using our mail form";

  }

else

//if "email" is not filled out, display the form

  {

  echo "<table>

<tr>

<form name='beställning' action='test.php' method='post'>

<td>Namn:

</td>

<td><input type='text' name='namn' length=50 />

</td>

</tr>

<tr>

<td>

Email:

</td>

<td><input type='text' name='email' length=50 />

</td></tr>

<tr>

<td>

Företagsnamn:

</td>

<td>

<input type='text' name='foretag' length=50 />

</td></tr>

<tr>

<td>

Hemsida:

</td>

<td><input type='text' name='hemsida' length=50 />

</td></tr>

<tr>

<td>Vi sysslar med:

</td>

<td><input type='text' name='bransch' length=50 />

</td></tr>

<tr>

<td>

Adress:</td>

<td>

<input type='text' name='adress' length=70 />

</td></tr>

<tr>

<td>

Tel:

</td>

<td><input type='text' name='tel' length=50 />

</td></tr>

<tr>

<td>

Vi vill uppnå: </td>

<td><select name='uppna'>

<option value='kunder'>Nå fler kunder</option>

<option value='varumarke'>Stärka varumärket</option>

<option value='lansera'>Lansera produkt</option>

<option value='hemsida'>Hemsida</option>

<option value='kris'>Hantera kris</option>

<option value='annat'>Annat, fyller i nedan</option>

</select>

</td></tr>

<tr>

<td>

Detta gör oss unika:</td>

<td>

<textarea rows='3' cols='30' name='unik'>Trevligast personal i stan och...</textarea>

</td></tr>

<tr>

<td>

Annat att ta med i beaktande:

</td>

<td><textarea rows='4' cols='30' name='annat'>

Inkludera ämne som du skulle vilja att ert paket fokuserar på, tex. miljöarbete, sommarkampanj!

</textarea></td></tr>

<tr>

<td>

Så här konservativ/liberal är jag när det gäller PR

<i>(ovanliga idéer ger större genomslag)</i>:

</td>

<td>

<select name='modig'>

<option value='1'>1 - traditionell</option>

<option value='2'>2</option>

<option value='3'>3</option>

<option value='4'>4</option>

<option value='5'>5 - fritänkare</option>

</select>

</td>

</tr>

<tr>

<td>

Acceptera beställningsvillkor <input type='checkbox' name='villkor' />

</td>

</tr>

<tr>

<td>

<input type='submit' value='Skicka' />

</form>

</td>

</tr>

</table>";

  }

?>

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/239465-mailing-form-problem/
Share on other sites

Still don't know what was wrong, but solved it! :D

 

Made each form box value into it's own variable before concatenating it in the $message variable. I thought I could request them and concatenate them into one variable ($message) at once...  :shrug:

 

Also had to remove '<br />\n' from the wordwrap function for it to work, which is weird.  :shrug:

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.