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
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?

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.