PHP - Mail($to,$sub,$body1, $headers); Doesnt Work
hello,
I host my website on a linux server, but when I click this code: mail($to,$sub,$body1, $headers); it does not send any mail. I dont get any error also. I know that it worked on other servers. what should I do? thanks Similar Tutorialsthe following isnt sending mail() Code: [Select] $to=$_POST['CustomerEmail']; $from = "s@xaa.com"; $Cc = "s@xaa.com"; $headers = "From:" . $from; $headers = "Cc:" . $Cc; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; i believe it's the dot before the equal sign I have an email form that is sending to an email address. There are five fields where the person sending can input their Name, Address, City, State, and Zip. Everything is working, except I want the input from these fields to be the the headers in the PHP email. For instance it submits and send the letter, but I want the senders Name, Address, City, State, and Zip to be posted after the "Sincerely" in the letter sent. Here is what the input boxes of the form looks like: Code: [Select] <p>Sincerely,<br /> <label for="from">Name:</label> <input type="text" name="from" id="name" value="<?php echo $_POST['from'];?>"/><br /> <label for="street">Street:</label> <input type="text" name="street" id="street" value="<?php echo $_POST['street'];?>"/><br /> <label for="city">City:</label> <input type="text" name="city" id="city" value="<?php echo $_POST['city'];?>"/><br /> <label for="zip">Zip:</label> <input type="text" name="zip" id="zip" value="<?php echo $_POST['zip'];?>"/><br /> <label for="email">E-mail:</label> <input type="text" name="email" id="email" value="<?php echo $_POST['email'];?>"/></p> <input type="submit" class="button" value="Submit" /> How do I go about posting the PHP headers in the email upon submission? When I test my php, all of the errors work, but when I actually want to send an email the form doesnt go through and I get the error message 'Please enter a valid e-mail address'? I think I may have something wrong in my mail function. Code: [Select] <?php if (empty($_POST['author'])) { $errors[] = 'Please enter a name'; } if (empty($_POST['subject'])) { $errors[] = 'Please enter a subject'; } if (empty($_POST['text'])) { $errors[] = 'Please enter your comments.'; } if (empty($_POST['email'])) { $errors[] = 'Please enter an e-mail'; } else if (!preg_match("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$ ^", $_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } if (count($errors) == 0) { // Process form mail("solysol05@gmail.com","Subject: subject", text,"From: author <email>"); echo "Thank you for using our mail form.<br/>"; echo "Your email has been sent."; } else { echo $errors[0]; } ?> OK so I am trying to send a email with the results of a submitted form to a specified email address. However when the email is received the data is not displayed rather the variable names are. See code and resulting email address below. // custom route code //Send Email // recipients $to = '********@*********.com'; // subject $subject = 'Jobs Form Submission!'; // message $message = ' <html> <head> <title>Jobs Form Submission!</title> </head> <body> Title: $job_title<br /> Company: $job_company<br /> Introduction: $job_intro <br /> Description: $job_description <br /> Required Qualifications: $job_req_qualifi <br /> Preferred Qualifications: $job_preerred_qualifi <br /> Contact Name: $job_contact_name <br /> Contact Company: $job_contact_company <br /> Contact E-mail: $job_contact_email <br /> Contact Phone: $job_contact_phone <br /> Contact Fax: $job_contact_fax <br /> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: ******** <********@*********.com>' . "\r\n"; $headers .= 'From: $job_contact_email <$job_contact_email>' . "\r\n"; $headers .= 'Cc:' . "\r\n"; $headers .= 'Bcc:' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); Email Address: Quote MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 To: ********<******@**********.com> From: $job_contact_email <$job_contact_email@***********.com> Cc: <html> <head> <title>Jobs Form Submission!</title> </head> <body> Title: $job_title<br /> Company: $job_company<br /> Introduction: $job_intro <br /> Description: $job_description <br /> Required Qualifications: $job_req_qualifi <br /> Preferred Qualifications: $job_preerred_qualifi <br /> Contact Name: $job_contact_name <br /> Contact Company: $job_contact_company <br /> Contact E-mail: $job_contact_email <br /> Contact Phone: $job_contact_phone <br /> Contact Fax: $job_contact_fax <br /> </body> </html> Any pointers would be great. Thanks in advance 0_o please help, here is all my code: <div id='div_phone_big'> </div> <head> <script type="text/JavaScript"> function getChoice(val) { yesNo = new Array("Yes", "No"); var getsel = document.contactus.yesnolist.value; var e = document.getElementById("yesnolist"); var strUser = e.options[e.selectedIndex].value; if (strUser == "no") { //alert('lakjdlakjsdlajd'); window.location.href = "http://www.rainbowcode.net/index.php/util/faq"; //document.write(window.location.href); window.location('http://www.rainbowcode.net/index.php/util/faq'); } else { document.contactus.emailreply.value = ""; document.contactus.commtext.value = ""; document.contactus.message.value = ""; document.contactus.commlist.value = ""; } return strUser; } function getCommChoice(x) { comm = new Array("Compliment","Complaint","Feedback","Suggestion","Billing Query","Other"); var getsel = document.contactus.commlist.value; document.contactus.message.value = comm[getsel]; return document.contactus.message.value; } function sayThanks() { alert("Thank you for submitting"); return true; } </script> </head> <body> <form name = "contactus" method="post" onSubmit="return sayThanks()"> <table class='table_format_content_rbc' border='0'> <div> <span class='spn_big_lightblue_rbc'>RAINBOW</span><span class='spn_big_black_rbc'>CODE: CONTACT US </span> <td colspan='3' align='left' class='small_header_rbc'> <h3>Problems and general queries</h3> <li>Phone our call centre on 086 110 6472 ( Available 8am-5pm from monday-friday ) or</li> <li>Email us at <a href="mailto:helloise@pagesalive.co.za">feedback@miranetworks.net</a> </li> </td> </div> <div> <tr></tr> <tr></tr> <tr> <td colspan='3' align='left' class='small_header_rbc'> <h3>Frequently Asked Questions</h3> <li>Please take a moment to read the Frequently Asked Questions as the solution to your query could be waiting for you there!</li> <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ? <select id="yesnolist" onChange="getChoice(this.value)"> <option value="yes" selected="selected">Yes</option> <option value="no">No</option> </select> </li> </tr> <tr></tr> <tr></tr> </div> <div> <tr> <td colspan='3' align='left' class='small_header_rbc'> <h3>Feedback and Suggestions</h3> </select> </li> <textarea name="message" rows="10" cols="20"></textarea> <br /><br /> <?php $to = "helloise@pagesalive.co.za"; $subject = $_REQUEST["commlist"]; $email = $_REQUEST["emailreply"]; $message = $_REQUEST["message"]; $headers = "From: $email"; mail($to, $subject, $message, $headers); ?> <input type="submit" value="Send"> <input type="reset" value="Reset"> </td> </tr> </div> </table> <table class='table_format_content_rbc' border='0'> <tr> <td colspan='3' align='left' class='small_header_rbc'> <br/> </td> <tr> </table> </form> </body> and also set the php.ini file portion: ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = /usr/sbin/sendmail -t and also ran: $ sudo echo "test" | mail -s "test" helloise@pagesalive.co.za The program 'mail' can be found in the following packages: * heirloom-mailx * mailutils please help?? <option value="feedback">Feedback</option> <option value="suggestion">Suggestion</option> <option value="billquery">Billing Query</option> <option value="other">Other</option> </select> </li> <textarea name="message" rows="10" cols="20"></textarea> <br /><br /> <?php $to = "helloise@pagesalive.co.za"; $subject = $_REQUEST["commlist"]; $email = $_REQUEST["emailreply"]; $message = $_REQUEST["message"]; $headers = "From: $email"; mail($to, $subject, $message, $headers); ?> <input type="submit" value="Send"> <input type="reset" value="Reset"> </td> </tr> </div> </table> <table class='table_format_content_rbc' border='0'> <tr> <td colspan='3' align='left' class='small_header_rbc'> <br/> </td> <tr> </table> </form> </body> and also set the php.ini file portion: ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = /usr/sbin/sendmail -t and also ran: $ sudo echo "test" | mail -s "test" helloise@pagesalive.co.za The program 'mail' can be found in the following packages: * heirloom-mailx * mailutils please help?? I have a strange problem with my headers in my mail function.
This is how it looks like in my code:
$to = 'someone@email.com'; $subject = 'Question from website'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html;charset=UTF-8' . "\r\n"; $headers .= 'From: ' . $email . "\r\n";When i send this i got the following message in my mailbox: Content-type: text/html;charset=UTF-8 From: web@somecompany.com Message-Id: <20140620142808.93D11A147@apache11.hostbasket.com> Date: Fri, 20 Jun 2014 16:28:08 +0200 (CEST) <html><head><title>Question from web</title><style type="text/css">body {background-color: #ffffff; font-family: verdana;}hr {color: #333;}div {width: 800px; margin: 25px auto;}h1 {color: #FFC421; font-size: 17px;}p {color: 2a2a2a; font-size: 15px;}</style></head><body><div><p><img src="imgs/tsc-logo.png"/></p><hr /><h2 style="color: #FFC421;">This customer asked a question</h2><br /><table style="width:800px"><tr><th style="width:250px"><h1>Customer:</h1></th><td></td></tr><tr><th>Name:</th><td>testname</td></tr><tr><th>Firstname:</th><td>testfirstname</td></tr><tr><th>E-mail:</th><td>testperson@company.be</td></tr><tr><th>Bericht:</th><td>This is a test</td></tr></table></div></body></html>I have allready found that the space between "Content-type" and "From" is not normal that indicates that a rule between MIME and Content-type is also present. But in my code there isn't any rule... How can this be possible? Thanks for the help! it doesnt write into the files, the file is created and everything and how would i echo the whole file? Code: [Select] if (isset($_POST['submit'])) { $firstname = ($_POST['firstname']); $lastname = ($_POST['lastname']); include ("cookieusername.php"); $filename = "***/$username.info.php" or exit("Unable to open file!"); $handle = @fopen($filename, 'x+')or die(mysql_error()); $content = "lololo"; @fwrite($handle, $content)or die(mysql_error()); @fclose($filename); } Code: [Select] function convert_youtube($code,$code1) { $youtube_count++; return '<embed src="http://'.$code.'youtube.com/v/'.$code1.'" type="application/x-shockwave-flash" wmode="transparent" width="512" height="313" allowfullscreen="true" />'; } echo $youtube_count; im trying to echo it out, i have like 5 flash videos on the bbcode parser: Code: [Select] $RegEx = '%(\[quote(?:=[^\]]*)\].*?)?\[youtube\]http\://(.*?)youtube\.com/watch\?v\=(.*?)\[/youtube\](.*?\[/quote\])?%ie'; if(preg_match_all($RegEx, $text, $matches,PREG_SET_ORDER)){ foreach($matches as $match){ if(!empty($match[0]) && empty($match[1]) && empty($match[4])){ $text = str_replace($match[0], convert_youtube($match[2],$match[3]), $text); }else{ $url = sprintf('http://%syoutube.com/watch?v=%s',$match[2],$match[3]); $text = str_replace($match[0], sprintf('%s<a href=\'%s\' target=\"_blank\">%s</a>%s',$match[1],$url,$url,$match[4]), $text); } } } if i do "echo "hey";" it works but not any variables.. zzzzzzzzzzzzzzzzz i made a submitter, that workes:
<?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO aktiviteter (`title`, `firma`, `beskrivelse`, `information`, `pris`, `rabat`, `adresse`, `by`, `postnummer`, `telefon`, `hjemmeside`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['title']), mysqli_real_escape_string($con, $_POST['firma']), mysqli_real_escape_string($con, $_POST['beskrivelse']), mysqli_real_escape_string($con, $_POST['information']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['rabat']), mysqli_real_escape_string($con, $_POST['adresse']), mysqli_real_escape_string($con, $_POST['by']), mysqli_real_escape_string($con, $_POST['postnummer']), mysqli_real_escape_string($con, $_POST['telefon']), mysqli_real_escape_string($con, $_POST['hjemmeside']) ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "Aktiviteten er uploaded"; mysqli_close($con);but then i changed a few parameters and now it doesnt. i cant figure out why <?php include 'sqlconnect.php'; $sql = sprintf( "INSERT INTO menus (`navn`, `kommentar`, `pris`, `target`) VALUES ('%s', '%s', '%s', '%s')", mysqli_real_escape_string($con, $_POST['navn']), mysqli_real_escape_string($con, $_POST['kommentar']), mysqli_real_escape_string($con, $_POST['pris']), mysqli_real_escape_string($con, $_POST['target']), ); if (!mysqli_query($con, $sql)) { die('Error: ' . mysqli_error($con)); } echo "menuen er uploaded"; mysqli_close($con);can anyone spot the mistake i made? I have the following code, and for some reason the nl2br() function doesnt work anymore it did until i added the pred_replace part: $topic = $_POST['topic']; $message = $_POST['message']; $board = $_POST['board']; $topic = stripslashes($topic); $message = stripslashes($message); $board = stripslashes($board); $topic = mysql_real_escape_string($topic); $message = mysql_real_escape_string($message); $board = mysql_real_escape_string($board); $message = nl2br($message); $message = preg_replace("/\[b\](.*)\[\/b\]/Usi", "<b>\\1</b>", $message); $message = preg_replace("/\[u\](.*)\[\/u\]/Usi", "<u>\\1</u>", $message); $message = preg_replace("/\[i\](.*)\[\/i\]/Usi", "<i>\\1</i>", $message); $message = preg_replace("/\[center\](.*)\[\/center\]/Usi", "<center>\\1</center>", $message); $message = preg_replace("/\[right\](.*)\[\/right\]/Usi", "<p align=right>\\1</p>", $message); $message = preg_replace("/\[url=http://(.*)\](.*)\[\/url\]/Usi", "<a href=\"\\1\">\\2</a>", $message); $message = preg_replace("/\[img=(.*)\]/Usi", "<img src=\"\\1\">", $message); $message = preg_replace("/\[profile=(.*)\](.*)\[\/profile\]/Usi", "<a href=\"index.php?step=profile&profile=\\1\">\\2</a>", $message); $message = preg_replace("/\[quote](.*)\[\/quote\]/Uis", "<div>Quote:</div><div style=\"border:solid 1px;\">\\1</div>", $message); I have a quite old book about database applications, and i got a problem with it. I have this page, create_entry.php Code: [Select] <?php include("dbconnect.php"); if ($submit == "Sign") { $query = "insert into DA_guestbook(name, location, email, url, comments) values ('$name', '$location', '$email', '$url', '$comments')"; mysql_query($query) or die (mysql_error()); ?> <h2>Thanks!!</h2> <h2><a href="view.php">View my guestbook!</a></h2> <?php } else { include("sign.php"); } ?> and i got this page named sign.php Code: [Select] <h2>Sign my guestbook</h2> <form method="post" action="create_entry.php"> <b>Name:</b> <input type="text" size="40" name="name"> </br> <b>Location:</b> <input type="text" size="40" name="location"> </br> <b>Email:</b> <input type="text" size="40" name="email"> </br> <b>Home Page Url:</b> <input type="text" size="40" name="url"> </br> <b>Comments:</b> <textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea> </br> <input type="submit" name="submit" value="Sign"> <input type="reset" name="reset" value="Start Over"> </form> When i open create_entry.php then sign.php is indeed shown up. However when i send, it brings me to the same page with no Thanks!! etc. Also nothing gets inserted in the database. Hope i explained well enough Hi guys, in code below I have a section where users can check seat avillability, however it shows the seats taken but it doest say the seats available, can u help me find out whats wrong? thanks in advance guys this is the line below $checkavailability=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND ride_id='$ride_id'"); while($row=mysql_fetch_array($checkavailability)) { $takenseats=$row['seat_no']; if (mysql_num_rows($checkavailability)>=1) { echo "<table>"; echo " <td>Seat No ".$takenseats." is taken</td> "; } else{ echo " <td>Seat No ".$takenseats." is Available</td> "; } } echo "</table>"; } ?> full code below: <?php session_start(); include ("includes/db.php"); include ("includes/function.php"); //authentication if (loggedin()==FALSE) { Header("Location: login.php"); exit(); } //username session $_SESSION['username']=='$username'; $username=$_SESSION['username']; echo "Welcome, " .$_SESSION['username']."!<p>"; //get details from user table to be passed to page(text fields) $getdetails=mysql_query("SELECT * FROM users WHERE username='$username'"); while($row = mysql_fetch_array($getdetails)) { $users_id=$row['id']; $first_name=$row['first_name']; $last_name=$row['last_name']; $email=$row['email']; } /////////////////////////////////////// //****************************// //post starts here if (isset($_POST['next']) && $_POST['next']) { $myfirstname = addslashes(strip_tags($_POST['firstname'])); $mylastname = addslashes(strip_tags($_POST['lastname'])); $myemail = addslashes(strip_tags($_POST['email'])); $mybookingdate = addslashes(strip_tags($_POST['datetime'])); $mytime = addslashes(strip_tags($_POST['time'])); $myseatnumber = addslashes(strip_tags($_POST['seatnumber'])); $ride_id=1; //check if booking exists $checkbooking=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND seat_no='$myseatnumber'"); if (mysql_num_rows($checkbooking)>=1) { echo "Seat No $myseatnumber For $mybookingdate at $mytime has been already taken, Please try a different seat, time or date"; } else { $checktotoal=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime'"); if (mysql_num_rows($checkbooking)>=48) { echo "We are fully book for this time and date, please choose different time/date to continue your booking"; } //pass the variables here } } if (isset($_POST['availability']) && $_POST['availability']) { $mybookingdate = addslashes(strip_tags($_POST['datecheck'])); $mytime = addslashes(strip_tags($_POST['timecheck'])); $myseatnumber = addslashes(strip_tags($_POST['seatnumbercheck'])); $ride_id=1; $checkavailability=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND ride_id='$ride_id'"); while($row=mysql_fetch_array($checkavailability)) { $takenseats=$row['seat_no']; if (mysql_num_rows($checkavailability)>=1) { echo "<table>"; echo " <td>Seat No ".$takenseats." is taken</td> "; } else{ echo " <td>Seat No ".$takenseats." is Available</td> "; } } echo "</table>"; } ?> <html> <head> <link type="text/css" href="css/smoothness/jquery-ui-1.8.6.custom.css" rel="stylesheet" /> <script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="includes/jquery-ui-1.8.6.custom.min.js"></script> <script type="text/javascript"> $(function() { $('#datetime').datepicker({ dateFormat: 'dd.mm.yy' }); }); $(function() { $('#datecheck').datepicker({ dateFormat: 'dd.mm.yy' }); }); </script> </head> <body> <table width="665" border="0"> <tr> <td width="372"><form name="booking" method="post" action=""> <p>BOOK NOW <p> First Name:<br /> <input type="text" name='firstname' value="<? echo "$first_name";?>"> <p>Last Name:<br /> <input type="text" name='lastname' value="<? echo "$last_name";?>"> <p>Email:<br /> <input type="text" name='email' value="<? echo "$email";?>"> <p>Choose a Date:<br /> <input type="text" name='datetime' id="datetime"> </p> <p> Select a Time:<br/> <select name='time'> <option value="9:00">9:00 <option value="9:07">9:07 <option value="9:14">9:14 <option value="9:21">9:21 <option value="9:28">9:28 <option value="9:35">9:35 <option value="9:42">9:42 <option value="9:49">9:49 <option value="9:56">9:56 <option value="10:03">10:03 <option value="10:10">10:10 <option value="10:17">10:17 <option value="10:24">10:24 <option value="10:31">10:31 <option value="10:38">10:38 <option value="10:45">10:45 <option value="10:52">10:52 <option value="10:59">10:59 <option value="11:02">11:02 <option value="11:09">11:09 <option value="11:16">11:16 <option value="11:23">11:23 <option value="11:30">11:30 <option value="11:37">11:37 <option value="11:44">11:44 <option value="11:51">11:51 <option value="11:58">11:58 </select> </p> <p> Select Seat Number:<br/> <select name='seatnumber'> <option value="1">Seat 1 <option value="2">Seat 2 <option value="3">Seat 3 <option value="4">Seat 4 <option value="5">Seat 5 <option value="6">Seat 6 <option value="7">Seat 7 <option value="8">Seat 8 <option value="9">Seat 9 <option value="10">Seat 10 <option value="11">Seat 11 <option value="12">Seat 12 <option value="13">Seat 13 <option value="14">Seat 14 <option value="15">Seat 15 <option value="16">Seat 16 <option value="17">Seat 17 <option value="18">Seat 18 <option value="19">Seat 19 <option value="21">Seat 20 <option value="22">Seat 22 <option value="23">Seat 23 <option value="24">Seat 24 <option value="25">Seat 25 <option value="26">Seat 26 <option value="27">Seat 27 <option value="28">Seat 28 <option value="20">Seat 29 <option value="30">Seat 30 <option value="31">Seat 31 <option value="32">Seat 32 <option value="33">Seat 33 <option value="34">Seat 34 <option value="35">Seat 35 <option value="36">Seat 36 <option value="37">Seat 37 <option value="38">Seat 38 <option value="39">Seat 39 <option value="40">Seat 40 <option value="41">Seat 41 <option value="42">Seat 42 <option value="43">Seat 43 <option value="44">Seat 44 <option value="45">Seat 45 <option value="46">Seat 46 <option value="47">Seat 47 <option value="48">Seat 48 </select> <p> <input type='submit' name='next' value='Next Step'> </form></td> <td width="283"> <form name="booking" method="post" action=""> <p>Check Seat Availability<br /> <p><br /> <p>Choose a Date:<br /> <input type="text" name='datecheck' id="datecheck"> <p> Select Seat Number:<br/> <select name='seatnumbercheck'> <option value="1">Seat 1 <option value="2">Seat 2 <option value="3">Seat 3 <option value="4">Seat 4 <option value="5">Seat 5 <option value="6">Seat 6 <option value="7">Seat 7 <option value="8">Seat 8 <option value="9">Seat 9 <option value="10">Seat 10 <option value="11">Seat 11 <option value="12">Seat 12 <option value="13">Seat 13 <option value="14">Seat 14 <option value="15">Seat 15 <option value="16">Seat 16 <option value="17">Seat 17 <option value="18">Seat 18 <option value="19">Seat 19 <option value="21">Seat 20 <option value="22">Seat 22 <option value="23">Seat 23 <option value="24">Seat 24 <option value="25">Seat 25 <option value="26">Seat 26 <option value="27">Seat 27 <option value="28">Seat 28 <option value="20">Seat 29 <option value="30">Seat 30 <option value="31">Seat 31 <option value="32">Seat 32 <option value="33">Seat 33 <option value="34">Seat 34 <option value="35">Seat 35 <option value="36">Seat 36 <option value="37">Seat 37 <option value="38">Seat 38 <option value="39">Seat 39 <option value="40">Seat 40 <option value="41">Seat 41 <option value="42">Seat 42 <option value="43">Seat 43 <option value="44">Seat 44 <option value="45">Seat 45 <option value="46">Seat 46 <option value="47">Seat 47 <option value="48">Seat 48 </select> <p> </p> <p> Select a Time:<br/> <select name='timecheck'> <option value="9:00">9:00 <option value="9:07">9:07 <option value="9:14">9:14 <option value="9:21">9:21 <option value="9:28">9:28 <option value="9:35">9:35 <option value="9:42">9:42 <option value="9:49">9:49 <option value="9:56">9:56 <option value="10:03">10:03 <option value="10:10">10:10 <option value="10:17">10:17 <option value="10:24">10:24 <option value="10:31">10:31 <option value="10:38">10:38 <option value="10:45">10:45 <option value="10:52">10:52 <option value="10:59">10:59 <option value="11:02">11:02 <option value="11:09">11:09 <option value="11:16">11:16 <option value="11:23">11:23 <option value="11:30">11:30 <option value="11:37">11:37 <option value="11:44">11:44 <option value="11:51">11:51 <option value="11:58">11:58 </select> <p> <input type='submit' name='availability' value='Check Availability'> </form> </td> </tr> </table> <p> </body> </html> i want to create function that calculate worker that attend 6 days activity on year B and group it by their gred. so i use this coding but it give wrong result Code: [Select] function countSix($a,$f) { $sql = "SELECT * FROM staf_info INNER JOIN aktiviti_staf ON staf_info.id=aktiviti_staf.id INNER JOIN aktiviti ON aktiviti_staf.id_aktiviti=aktiviti.id_aktiviti WHERE staf_info.id_kumpulan = '".$a."' AND year(tarikh_awal) LIKE '%".$f."'"; $query= mysql_query($sql) or die("Error: " .mysql_error()); $row=mysql_num_rows($query); $num=1; $f=0; if($row!=0) { while( $data=mysql_fetch_assoc($query)) { $b=$data['bil_hari']+$data['hari_kursus']; if($b == 6) { $e = countStaf($data['id'],$data['id_aktiviti']); $f = $f + $e; } } } return $f; } function countStaf($c,$d) { $sql = "SELECT COUNT(*) AS STAFCOUNT FROM aktiviti_staf WHERE id = '".$c."' AND id_aktiviti = '".$d."'"; $query= mysql_query($sql) or die("Error: " .mysql_error()); $row=mysql_num_rows($query); $result = mysql_fetch_array($query); return $result['STAFCOUNT']; } i can't seem to find the error.. help me please!! im trying to connect to our office server by remote desktop.. but when i do it..alot of error came out from my index.php and counter.php.. does anyone ever experience these problems? what should i do.. Hi, Im using a button to delete each entry from my database, however it doesnt. I have tried it with linking to a delete page and works fine with the same mysql query, but i need to hve the button to delete and not a URL. Can someone please help me to see what is wrong? thanks in advance guys <?php include ("../include/global.php"); include ("../include/function.php"); if (loggedin()==FALSE) { Header("Location: ../login.php"); exit(); } $_SESSION['username']=='$username'; $username=$_SESSION['username']; $getid=mysql_query("SELECT id FROM users WHERE username='$username'"); while($row=mysql_fetch_array($getid)) { $usersid=$row['id']; } if (isset($_POST['add']) && $_POST['add']) { $subject = addslashes(strip_tags($_POST['subject'])); $text = addslashes(strip_tags($_POST['text'])); $update=mysql_query("INSERT INTO users_notes (user_id, subject, note) VALUES ('$usersid','$subject','$text')"); } if (isset($_POST['remove']) && $_POST['remove']) { $delete=mysql_query("DELETE FROM users_notes WHERE user_id='$usersid' AND AND id='$id'"); } ?> <html> <head> <script type="text/javascript" src="/js/jquery.js"></script> <script type="text/javascript" src="/js/jquery.validate.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#form").validate(); }); </script> </head> <body> <p>You are logged in! <a href="logout.php">Log out</a> </p> <p> </p> <p><td><? $getmsg=mysql_query("SELECT * FROM users_notes WHERE user_id='$usersid'"); while($row=mysql_fetch_array($getmsg)) { $id=$row['id']; $msgsubject=$row['subject']; $msgnotes=$row['note']; echo"<table width='800' border='1'>"; echo" <tr> <td width='50'>".$msgsubject."</td> <td width='50'>".$msgnotes."</td> <td width='40'><form id='form' method='post' action=''> <input type='submit' name='remove' value='remove' /> </form></td> <td> </td> </tr> "; } echo "</table>"; ?> </td> </p> <p> </p> <form action="" method="POST" id="form"> <p> Subject: <br/> <input type="text" name="subject" class="required"> </p> <p> Your Note: <br/> <textarea name="text" id="text" cols="45" rows="15" class="required"></textarea> </p> <p> <input type="submit" name="add" value="Add" > </p> </form> </body> Hi I am trying to incorporate a login form on my main page from WHMCS but nothing happens I did an include ('login2.php'); and in that login2.php here is the code: Code: [Select] <?php echo date("l F jS Y "); require("./billing/dbconnect.php"); require("./billing/includes/functions.php"); require("./billing/includes/clientareafunctions.php"); if ($_SESSION['uid']) { $result = mysql_query("SELECT firstname,lastname FROM tblclients WHERE id=" . $_SESSION['uid'] . ""); $data = mysql_fetch_array ($result); echo "<hr/><strong>Welcome Back</strong><br>"; echo "<strong>{$data['firstname']}</strong> "; echo "<strong>{$data['lastname']}</strong><br><br>"; echo "<br><br><form method=post action=http://store.crytell.com/billing/logout.php><input type=submit class=submitbutton value=Logout /></form>"; } else { echo '<form method="post" action="http://store.crytell.com/billing/dologin.php?goto=clientarea"> <input type="hidden" name="token" value="##removed##" /> Email Address: <input type="text" name="username" size="50"><br> Password: <input type="password" name="password" size="20"><br> <input type="submit" value="Login"> </form>'; } ?> when I go directly to the login script it works but when I include it in my homepage nothing happens any help? Hello I have this script that I have been getting support on on other forums and I would really love some help. What this script does is reset your password to a randomly generated one, but for security it asks you a secret question that you have to answer correctly, for it to generate a random password, update that password into the database table and then email you it. Everything works, like the security question part, finding the email works, and sending the email works. But the only part that doesnt work is the updating the table with the randomly generated password. Here is the code. <?php function checkUNEmail($uname,$email) { global $mySQL; $userID = 'X'; $error = array('status'=>false,'userID'=>0); if (isset($email) && trim($email) != '') { //email was entered if ($SQL = $mySQL->prepare("SELECT `ID` FROM `users` WHERE `Email` = ? LIMIT 1")) { $SQL->bind_param('s',trim($email)); $SQL->execute(); $SQL->store_result(); $numRows = $SQL->num_rows(); $SQL->bind_result($userID); $SQL->fetch(); $SQL->close(); if ($numRows >= 1) return array('status'=>true,'userID'=>$userID); } else { return $error; } } elseif (isset($uname) && trim($uname) != '') { //username was entered if ($SQL = $mySQL->prepare("SELECT `ID` FROM users WHERE Username = ? LIMIT 1")) { $SQL->bind_param('s',trim($uname)); $SQL->execute(); $SQL->store_result(); $numRows = $SQL->num_rows(); $SQL->bind_result($userID); $SQL->fetch(); $SQL->close(); if ($numRows >= 1) return array('status'=>true,'userID'=>$userID); } else { return $error; } } else { //nothing was entered; return $error; } } function getSecurityQuestion($userID) { global $mySQL; $questions = array(); $questions[0] = "What is your mother's maiden name?"; $questions[1] = "What city were you born in?"; $questions[2] = "What is your favorite color?"; $questions[3] = "What year did you graduate from High School?"; $questions[4] = "What was the name of your first boyfriend/girlfriend?"; $questions[5] = "What is your favorite model of car?"; if ($SQL = $mySQL->prepare("SELECT `secQ` FROM `users` WHERE `ID` = ? LIMIT 1")) { $SQL->bind_param('i',$userID); $SQL->execute(); $SQL->store_result(); $SQL->bind_result($secQ); $SQL->fetch(); $SQL->close(); return $questions[$secQ]; } else { return false; } } function checkSecAnswer($userID,$answer) { global $mySQL; if ($SQL = $mySQL->prepare("SELECT `Username` FROM `users` WHERE `ID` = ? AND LOWER(`secA`) = ? LIMIT 1")) { $answer = strtolower($answer); $SQL->bind_param('is',$userID,$answer); $SQL->execute(); $SQL->store_result(); $numRows = $SQL->num_rows(); $SQL->close(); if ($numRows >= 1) { return true; } } else { return false; } } function sendPasswordEmail($userID) { global $mySQL; changePassword($userID); if ($SQL = $mySQL->prepare("SELECT `Username`,`Email`,`Password` FROM `users` WHERE `ID` = ? LIMIT 1")) { $SQL->bind_param('i',$userID); $SQL->execute(); $SQL->store_result(); $SQL->bind_result($uname,$email,$password); $SQL->fetch(); $SQL->close(); $message = "Dear $uname,\r\n"; $message .= "Here is your requested lost password for your account at our site:\r\n"; $message .= "-----------------------\r\n"; $message .= "$password\r\n"; $message .= "-----------------------\r\n"; $message .= "Our login page: <a href=\"login.php\">http://www.oursite.com/login.php</a>\r\n\r\n"; $message .= "Thanks,\r\n"; $message .= "-- Our site team"; $headers .= "From: Our Site <webmaster@oursite.com> \n"; $headers .= "To-Sender: \n"; $headers .= "X-Mailer: PHP\n"; // mailer $headers .= "Reply-To: webmaster@oursite.com\n"; // Reply address $headers .= "Return-Path: webmaster@oursite.com\n"; //Return Path for errors $headers .= "Content-Type: text/html; charset=iso-8859-1"; //Enc-type $subject = "Your Lost Password"; @mail($email,$subject,$message,$headers); return str_replace("\r\n","<br/ >",$message); } } function genRandomString() { $length = 10; $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; $string = ''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } function changePassword($userID){ global $mySQL; $password = genRandomString(); $SQL = $mySQL->prepare('UPDATE `users` SET `Password`="'.$password.'" WHERE `ID`="?" LIMIT 1'); $SQL->bind_param('s',$password); $SQL->bind_param('i',$userID); $SQL->execute(); return $password; } ?> The last 2 functions in the code are where the passwords are supposed to get changed and updated in the table, but it doesn't work... Can anyone help me out please In Firefox and Google Crome my code works correct, but in IE it doesnt. The problem is that before or after loading a page in IE, $_SESSION is unsetted. If i set $_SESSION['online'] = 1, then after reloading the page then print_r($_SESSION) outputs nothing. if ($btn){ if((!empty($filename)) && ($error == 0)) { if (($filetype == "image/jpeg" || $filetype == "image/jpg" || $filetype == "image/gif" || $filetype == "image/png") && ($filesize < 4508876)) { $moving_flag = true; $moving_msg = "Your image has been uploaded!"; } else { $upl_error_msg = "Error: Only jpg/gif/png images under 4Mb are accepted for upload"; $upl_error_flag = true; } } else { $upl_error_msg = "Error: No file uploaded"; $upl_error_flag = true; } } Why the above code wont work on IE and wont show me "Your image has been uploaded!" message when i have a valid type and size? it works on chrome and FF page 1 is this session_start(); include 'db.php'; $email = $_POST['email']; $password = $_POST['password']; $email = stripslashes($email); $password = stripslashes($password); $email = mysql_real_escape_string($email); $password = mysql_real_escape_string($password); $sql="SELECT * FROM directory WHERE email='$email' and password='$password' "; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ $wtf="SELECT * FROM directory WHERE email='$email' and password='$password' "; while($row = mysql_fetch_array($wtf)) { $fname = $row['fname']; $lname = $row['lname']; $address = $row['address1']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; } $_SESSION['user'] = $email; $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['address1'] = $address; $_SESSION['city'] = $city; $_SESSION['state'] = $state; $_SESSION['zip'] = $zip; $_SESSION['status'] = "1"; page two is just: only the user and status works. session_start(); echo $_SESSION['user'] ; echo $_SESSION['fname'] ; echo $_SESSION['lname'] ; echo $_SESSION['address1']; echo $_SESSION['city'] ; echo $_SESSION['state'] ; echo $_SESSION['zip']; echo $_SESSION['status']; why is that not working |