Jump to content

Problem with small emailing form.


unistake

Recommended Posts

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

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?

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.