PHP form mail

Discussion in 'PHP' started by matik, Dec 28, 2006.

  1. #1
    Hi! I'm newbie in DP and also in PHP. Can anybody helps me with this mail form? Witch php code must i use, that it will works?

    <form>
      <table width="485" height="246" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
        <tr>
          <td width="147" height="21" bgcolor="#CCCCCC">Form 1:</td>
          <td width="326" bgcolor="#CCCCCC">
          <input name="imepriimek" type="text" size="50" />
          </td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 2:</td>
          <td bgcolor="#CCCCCC"><input name="email" type="text" size="50" /></td>
        </tr>
        <tr>
          <td height="21"></td>
          <td></td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 3:</td>
          <td bgcolor="#CCCCCC"><input name="domena" type="text" size="50" /></td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 4:</td>
          <td bgcolor="#CCCCCC"><input name="uporime" type="text" size="17" /></td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 5:</td>
          <td bgcolor="#CCCCCC"><input name="geslo" type="text" size="17" /></td>
        </tr>
        <tr>
          <td height="24" bgcolor="#CCCCCC">Form 6:</td>
          <td bgcolor="#CCCCCC">
            <select name="paket" size="1">
              <option>1</option>
              <option>2</option>
              <option>3</option>
            </select>     </td>
        </tr>
        <tr>
          <td height="24"></td>
          <td></td>
        </tr>
        <tr>
          <td height="24" bgcolor="#CCCCCC"><p>Form 7:</p>
            <p></p>
          <p></p>
          <p></p>
          <p></p></td>
          <td bgcolor="#CCCCCC">
            <textarea name="opomba" cols="40" rows="10"></textarea>
          </td>
        </tr>
        <tr>
          <td height="24" bgcolor="#CCCCCC"></td>
          <td bgcolor="#CCCCCC"><input type="reset" name="Submit2" value="Reset" />
               <input type="submit" name="Submit" value="Submit" /></td>
        </tr>
      </table>
    </form>
    HTML:
    P.S: Sorry for my English:)
     
    matik, Dec 28, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    
    <?
    if($_POST)
    {
    	foreach($_POST as $key => $value)
    	{
    	 	if($key != "Submit")
    		$msg .= "$key = $value\n";
    	}
    	echo $msg;
    	if($msg)
    	{
    		mail("you@yourdomain.com", "Subject", $msg);
    	}
    }
    ?>
    <form method=post>
      <table width="485" height="246" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
        <tr>
          <td width="147" height="21" bgcolor="#CCCCCC">Form 1:</td>
          <td width="326" bgcolor="#CCCCCC">
          <input name="imepriimek" type="text" size="50" />
          </td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 2:</td>
          <td bgcolor="#CCCCCC"><input name="email" type="text" size="50" /></td>
        </tr>
        <tr>
          <td height="21"></td>
          <td></td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 3:</td>
          <td bgcolor="#CCCCCC"><input name="domena" type="text" size="50" /></td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 4:</td>
          <td bgcolor="#CCCCCC"><input name="uporime" type="text" size="17" /></td>
        </tr>
        <tr>
          <td height="21" bgcolor="#CCCCCC">Form 5:</td>
          <td bgcolor="#CCCCCC"><input name="geslo" type="text" size="17" /></td>
        </tr>
        <tr>
          <td height="24" bgcolor="#CCCCCC">Form 6:</td>
          <td bgcolor="#CCCCCC">
            <select name="paket" size="1">
              <option>1</option>
              <option>2</option>
              <option>3</option>
            </select>     </td>
        </tr>
        <tr>
          <td height="24"></td>
          <td></td>
        </tr>
        <tr>
          <td height="24" bgcolor="#CCCCCC"><p>Form 7:</p>
            <p></p>
          <p></p>
          <p></p>
          <p></p></td>
          <td bgcolor="#CCCCCC">
            <textarea name="opomba" cols="40" rows="10"></textarea>
          </td>
        </tr>
        <tr>
          <td height="24" bgcolor="#CCCCCC"></td>
          <td bgcolor="#CCCCCC"><input type="reset" name="Submit2" value="Reset" />
               <input type="submit" name="Submit" value="Submit" /></td>
        </tr>
      </table>
    </form>
    
    PHP:
    Will build a basic email and send it to the address provided, you'l need to set the email near the top of the page ...
     
    krakjoe, Dec 28, 2006 IP
  3. matik

    matik Peon

    Messages:
    3,471
    Likes Received:
    169
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hmm.. When i click submit, it don't sent mail, but tells this: imepriimek = test email = test domena = test uporime = test geslo = test paket = 2 opomba = test
     
    matik, Dec 28, 2006 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    remove echo $msg, that was just to show you the email it creates, and change to your email address
     
    krakjoe, Dec 28, 2006 IP
  5. matik

    matik Peon

    Messages:
    3,471
    Likes Received:
    169
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I did all that's you wrote, but nothing happend...
     
    matik, Dec 28, 2006 IP
  6. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #6
    what do you mean nothin happened ?

    you fill in the form and press send and if you have access to sendmail or smtp for a windows machine the mail will be sent, definately.
     
    krakjoe, Dec 28, 2006 IP
  7. matik

    matik Peon

    Messages:
    3,471
    Likes Received:
    169
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'll pm you
     
    matik, Dec 28, 2006 IP
  8. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #8
    Are you using mail on IIS, it won't work.

    Peace,
     
    Barti1987, Dec 28, 2006 IP