הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   עזרה בשליחת מייל php (https://hosts.co.il/forums/showthread.php?t=86545)

broyer50 01-12-10 23:19

עזרה בשליחת מייל php
 
אוקי אז יש לי באתר איזה קטגורית צור קשר ואני רוצה אפשרות לשליחת מייל דרך האתר בעזרת PHP
אז הטופס ב Html נראה ככה:

קוד:


<form method="post" action="mail.php">
<p>Name*</p><input type="text" name="customer_name" />
<br/>
<p>Email*</p><input type="text" name="email"/>
<br/>
<p>Telephone</p> <input type="text" name="subject" />
<br/><br/>
 Comment*<br/> <textarea rows="6" cols="40" type="text" name="comment"></textarea>
<br/><br/>
<input type=reset value="Reset">
 <input type=submit value="Send">     
</form>

עכשיו אני צריך לבנות את הקובץ mail.php ואני לא יודע איך וגם לא בדיוק יש לי זמן.. ניסיתי כל מיני סקריפטים שאנשים כתבו וניסיתי להתאים אותם לטופס הזה.. בהרבה מקרים זה שלח את המייל אבל לא את מה שהוזן אלה רק את השם.. כלומר אם ב comment רשמתי משהו אז זה לא שולח את מה שרשמתי אלה רק את השם comment..
בנוסף רציתי שיהיה תנאי שחייבים להזין שם אימייל ואת ההערה..
תודה מראש

Insane 02-12-10 00:44

http://www.upload.co.il/stage/studio...ion.asp?id=431

mrns 02-12-10 14:11

HTML
קוד:

<form method="post" name="sendm" action="mail.php">
        <p>Name*</p>
                <input type="text" name="customer_name" />
        <br/>
        <p>Email*</p>
                <input type="text" name="email"/>
        <br/>
        <p>Telephone</p>
                <input type="text" name="phone" /><br/>
        <br/>
        Comment*<br/>
                <textarea rows="6" cols="40" type="text" name="comment"></textarea>
        <br/>

        <br/>
        <input type="reset" value="Reset">
        <input type="submit" name="sendm" value="Send">     
</form>

PHP

קוד:

<?php

$name = $_POST['customer_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comment = $_POST['comment'];

if(isset($_POST['sendm']) && $name != "" && $email != "" && $phone != "" && $comment != "")  {   
    $mail_to = "המייל שלך כאן";

    $subject = "הודעה חדשה מהאתר";
        $message = "Name : $name<br />Email : $email<br />Telephone : $phone<br /><br />Comment: $comment";

        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=windows-1255' . "\r\n";

        mail($mail_to, $subject, $message, $headers);

    print '<script>alert("ההודעה נשלחה.")
    location.replace("index.html")</script>';
}
else    {
        print '<script>alert("ישנם פרטים חסרים בטופס.")
        location.replace("mail.html")</script>';
}

?>



כל הזמנים הם GMT +2. הזמן כעת הוא 07:51.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ