Page 2 of 3

Posted: Tue Aug 09, 2005 10:37 am
by s.dot
bla5e wrote:then how would it know who it is accepting?
because if($_GET['yes']) is just checking if the variable is there.. it doesn't lose its value.

the value of $_GET['yes'] is the person's ID (what you were calling $_GET['id'] in your script

Posted: Tue Aug 09, 2005 10:37 am
by bla5e
i dont think im understanding you correctly..

can you post what you mean?

Posted: Tue Aug 09, 2005 10:40 am
by s.dot

Code: Select all

<?php 
if ($_GET['yes'])
{ 
     $con = mysql_connect($server, $user, $password) or die ('I cannot connect to the database because: ' . mysql_error()); 
        mysql_select_db($database); 
        echo mysql_error(); 
        $sql = "SELECT * FROM `join` where `id` = '".$_GET['yes']."'"; 
        $result = mysql_query($sql, $con) or die(mysql_error()); 
        echo mysql_error(); 
        while ($data = mysql_fetch_assoc($result)) { 
        echo ("<br>"); 
        echo ("<form method=\"post\" action=\"yesp2=".$_GET['yes'].""); 
        echo ("<input name=\"email\" type=\"text\" value=\"".$data['email']."\" disabled> "); 
        echo ("<textarea col=25 rows=20 name=mail>"); 
        echo ("<input type=submit name=submit value=Add>"); 
        echo ("</form"); 
        } 
    }     

?>
That code should work.

It checks to see if $_GET['yes'] is set in the URL string (which it is, it's = to an id number.

Then it performs the query based on the value of $_GET['yes'] which is an id number.

Posted: Tue Aug 09, 2005 10:46 am
by bla5e
thanks! it works!!

but theres a problem...
when i click the 'Add' button (to send the mail message) it goes to

view.php?yesp2=19<input%20name=


nvm i figured it out... i didnt have '>' to end the form tag

Posted: Tue Aug 09, 2005 10:48 am
by s.dot
give me a moment I'm going to clean your code up for you a bit :)

Posted: Tue Aug 09, 2005 10:49 am
by bla5e
yesp2 doesnt do anything (wont mail or delete from mysql)

Code: Select all

<?php
if($_GET['yesp2']) { 
     if($_GET['yesp2'] == $_GET['id'])      { 
		$con = mysql_connect($server, $user, $password) or die ('I cannot connect to the database because: ' . mysql_error()); 
		mysql_select_db($database);
		echo mysql_error();
		$del = "DELETE FROM `join` WHERE `id` = '".$_GET['id']."'";
		$sql1 = "SELECT * FROM `join` where `id` = '".$_GET['id']."'";
		$result = mysql_query($sql1, $con) or die(mysql_error());
		echo mysql_error();
		while ($data = mysql_fetch_assoc($result)) {
			$mail = $_POST['mail'];
			$AdminMessage .= $mail;
			mail("".$data['email']."", "Team Exile", $AdminMessage, "From: join@teamexileonline.com");
		}
		mysql_query($del, $con) or die(mysql_error());		
		echo mysql_error();
		echo ("<br>Deleted from Requests & Sent mail to user for acceptance.");
  		} 
	} 	
?>

Posted: Tue Aug 09, 2005 10:59 am
by s.dot

Code: Select all

<?
if($_GET['yes'])
{ 
	$con = mysql_connect($server, $user, $password); 
	mysql_select_db($database, $con); 
	$result = mysql_query("SELECT * FROM `join` where `id` = '".$_GET['yes']."'");
	while($data = mysql_fetch_assoc($result))
	{
		echo ("<br>"); 
		echo ("<form method=\"post\" action=\"yesp2=".$_GET['yes'].""); 
		echo ("<input name=\"email\" type=\"text\" value=\"".$data['email']."\" disabled> "); 
		echo ("<textarea col=25 rows=20 name=mail>"); 
		echo ("<input type=submit name=submit value=Add>"); 
		echo ("</form"); 
	} 
}

if($_GET['yesp2'])
{ 
	$con = mysql_connect($server, $user, $password); 
	mysql_select_db($database, $con);
	$mail = $_POST['email']; 
	$AdminMessage = "whateveryouwanthere";
	mail($mail, "Team Exile", $AdminMessage, "From: join@teamexileonline.com"); 
	mysql_query("DELETE FROM `join` WHERE `id` = '".$_GET['id']."'");
	echo ("<br>Deleted from Requests & Sent mail to user for acceptance.");
} 
}
?>
Improvised and cleaned code. Should work.

Posted: Tue Aug 09, 2005 11:09 am
by bla5e
i changed some things about yesp2, but it says that its sending the email & deleting from the mysql.. but its not

Code: Select all

<?php
if($_GET['yesp2']) { 
    $con = mysql_connect($server, $user, $password); 
    mysql_select_db($database, $con); 
    $email = $_POST['email'];
    $mail = $_POST['mail']; 
    $AdminMessage = $mail; 
    mail($email, "Team Exile", $AdminMessage, "From: join@teamexileonline.com"); 
    mysql_query("DELETE FROM `join` WHERE `id` = '".$_GET['id']."'"); 
    echo ("<br>Deleted from Requests & Sent mail to user for acceptance."); 
} 
?>

Posted: Tue Aug 09, 2005 11:14 am
by s.dot
in the delete query, change $_GET['id'] to $_GET['yesp2']
that will work.

As far as the mail goes
print out your variables to see if they're really there

Code: Select all

echo $mail;
echo "<BR>";
echo $AdminMessage;
echo "<BR>";

Posted: Tue Aug 09, 2005 11:16 am
by bla5e
yea variables are there
i tried echo $email

but that didnt show anything

Posted: Tue Aug 09, 2005 11:18 am
by s.dot
then it should be fine.

Code: Select all

if(mail($,$,$,$))
{
  // do nothing
} ELSE
{
   echo "mail could not be sent";
}

Posted: Tue Aug 09, 2005 11:26 am
by bla5e
$_POST['email']
isnt being, well, posted...

the form:

Code: Select all

echo ("<input name=\"email\" type=\"text\" value=\"".$data['email']."\" disabled><br> ");

the mailer:

Code: Select all

$email = $_POST['email'];
$mail = $_POST['mail']; 
$AdminMessage = $mail; 
mail($email, "Team Exile", $AdminMessage, "From: join@teamexileonline.com");

Posted: Tue Aug 09, 2005 11:29 am
by s.dot
is there a value being posted.. like written in the form and then submitted?

Also, where is $_POST['mail'] coming from?

Posted: Tue Aug 09, 2005 11:30 am
by bla5e
post mail = the textarea, or the body of the email.

on the mailer form itself, it shows the email in the input form thing.. but it wont send it to the mailer.

Posted: Tue Aug 09, 2005 11:32 am
by s.dot

Code: Select all

echo ("<form method=\"post\" action=\"yesp2=".$_GET['yes']."");
try changing this to

Code: Select all

echo ("<form method=\"post\" action=\"".$_SERVER['php_self']."?yesp2=".$_GET['yes']."");