unistake Posted October 25, 2010 Share Posted October 25, 2010 Hi all, I have a simple script that does not work! I think it may be to do with $num = mysqli_num_rows($result) and $row = mysqli_assoc_result($result). I have tried echoing the value which works if I put it above the include("cxn.php");. The code is: <?php include("cxn.php"); $sql = "SELECT * FROM table WHERE email='$_POST[email]'"; $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); $num = mysqli_num_rows($result); $row = mysqli_fetch_assoc($result); if ($num > 0) { $to = "$_POST[email]"; $subj = "from the website"; $mess = "Your value is".$row['value']; $mailsend = mail($to,$subj,$mess,$headers); echo "email sent to $_POST['email']"; } else { echo "email not found!";} ?> Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/ Share on other sites More sharing options...
revraz Posted October 25, 2010 Share Posted October 25, 2010 Any errors? What doesn't work? You have a $headers variable, but nothing is in it. Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126131 Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 That is all the php page, it does not show any errors. Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126133 Share on other sites More sharing options...
revraz Posted October 25, 2010 Share Posted October 25, 2010 Maybe it is working but it's being filtered as Junk Mail. Did you check the server log to see if it's getting sent? Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126136 Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 I am not getting the email and the echo after the email is not showing. Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126138 Share on other sites More sharing options...
revraz Posted October 25, 2010 Share Posted October 25, 2010 Check your server log, do you have a SMTP server setup? Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126139 Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 Yes the email from the site works fine and I have checked the SMTP, I have another script from which I copied and pasted the email part of this script above. if I put echo $_POST['email'] after the $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); it does not work. Any ideas? Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126141 Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 anyone? Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126235 Share on other sites More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 I have tried echoing the value which works if I put it above the include("cxn.php");. Sounds like there's an error in cxn.php... Also if 'die' is reached and executed, then there is no more execution, so if it works before but not after then it must be between. Logicalsss Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126238 Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 ofcourse! but there is not a problem with it. I use the same include("cxn.php") for the rest of the site. The webpages are in the same directory. Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126241 Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 This works.. <?php include("cxn.php"); $sql = "SELECT * FROM Members WHERE email='$_POST[email]'"; $result = mysqli_query($cxn,$sql) or die("Cant execute query!"); $row = mysqli_fetch_assoc($result); echo $row['field']; ?> the script does not work when I include the $num = mysqli_num_rows($result) and also the email part of the script. Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126242 Share on other sites More sharing options...
mentalist Posted October 25, 2010 Share Posted October 25, 2010 When you say "does not work", please give the actual details otherwise were guessing... Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126252 Share on other sites More sharing options...
unistake Posted October 25, 2010 Author Share Posted October 25, 2010 got it to work somehow! I started to write it again and it works?! Link to comment https://forums.phpfreaks.com/topic/216767-problem-with-small-emailing-form/#findComment-1126254 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.