درخواست: راهنمایی برای فرم PHP
سلام
من واسه صفحه support سایتم یه فرمی رو درست کردم ( البته طراح سایت این کارو کرد :5:) اما مقدار OS رو تو ایمیلی که واسم ارسال می کنه undefine مینویسه :13:
ممنون میشم یه نگاه بندازید و بگید مشکل از کجاست...:10:
[HTML]
<form action="support.php" method="post" id="contactform">
<ol>
<li>
<label for="name">Username : <span class="red">*</span></label>
<input id="username" name="username" class="text" />
</li>
<li>
<label for="name">Password : <span class="red">*</span></label>
<input id="password" name="password" class="text" />
</li>
<li>
<label for="name">OS : <span class="red"></span></label>
<select name="os">
<option value="xp">XP</option>
<option value="seven">Seven</option>
<option value="Vista">Vista</option>
<option value="Linux">Linux</option>
<option value="Mac">Mac</option>
<option value="more">More...</option>
</select>
</li>
<li>
<label for="name">Error Number : <span class="red"></span></label>
<input style="width:200px;" id="error" name="error" class="text" />
</li>
<li>
<label for="email">Your email <span class="red">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="email">Subject <span class="red">*</span></label>
<input id="subject" name="subject" class="text" />
</li>
<li>
<label for="message">Question <span class="red">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
<div class="clr"></div>
</li>
</ol> <input type="submit" name="submit" value="ارسال تیکت"/><p style="margin-bottom:20px;"></p>
</form>
</div>
</div>
</div>
</body>
<p> </p>
<p> </p>
</html>
[/HTML]
[PHP]<?php
error_reporting('~EALL');
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('email','message','subject','username','password' ,'os','error');
$required = array('email','message','subject','username','pass word','os','error');
$your_email = "support@mihandata.net";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'email' && $key != 'subject') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(@mail($your_email,$email_subject,$email_content )) {
echo '<font style="color:#62af23">Your Message successfully Sent !</div>';
} else {
echo 'ERROR!';
}
}
?>[/PHP]