Return to Snippet

Revision: 26416
at April 27, 2010 17:57 by skyeriquelme


Updated Code
<?php
	// inputs: $to, $title, $tags, $subj, $code
	// computed: $id, $sys
	$errmsg = '';
	$sys  = $_SERVER['SERVER_NAME']; $sys=str_replace("www.","",$sys);
	$id   = $_SERVER['REMOTE_ADDR']; if ($_SERVER['REMOTE_HOST']!='') $id.=' '.$_SERVER['REMOTE_HOST'];
	$to   = $_REQUEST['to'];
	if ($to=='')
		{ $errmsg = "A destination address is required.<br>"; }
	else if (!stristr($to,$sys))
		{ $errmsg = "Invalid destination: ".$to."<br>Domain must be: ".$sys."<br>"; }
	$title = $_REQUEST['title'];
	$tags = $_REQUEST['tags'];
	$subj = $_REQUEST['subj'];
	$msg  = $_REQUEST['code'];
	
	// connect to references data base
$username="";
$password="";
$database="";

	//put data into database
	
$createdby="skye";
$created= $_REQUEST['who'];
$type="video";
$url="blanck";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO references VALUES ('$title','$createdby','$created','$tags','$msg','$type','$url')";
mysql_query($query);

mysql_close();

?>
<center>
<table border=1 bgcolor=#ffffff cellspacing=0 cellpadding=2><tr><td>
	<font face="verdana,arial,helvetica" size=-2>
	<i>Titulo:</i> <?php echo $title ?> &lt;<?php echo $from ?>&gt; [IP: <?php echo $id ?>]<br>
	<i>TAGs:</i> <?php echo $tags ?><br>
	<i>SUBJECT:</i> <?php echo $subj ?><br>
	</font>
</td></tr><tr><td align=center>
	<font face="verdana,arial,helvetica" size=-2><b><?php
		if ($errmsg!="") echo $errmsg."Please try again.";
		else { // send message
		      mail($to,$subj,'[ Visitor IP: '.$id." ]\n\n".$title."\n".$tags." ".$createdby." ".$created." ".$url." ".$type."\n".$msg."\n\n From: <".$from.'>');
			echo "Thank you. Your message has been sent";
		}
	?><b></font>
</td></tr></table>
</center>

Revision: 26415
at April 27, 2010 17:40 by skyeriquelme


Initial Code
<?php
	// inputs: $to, $title, $tags, $subj, $code
	// computed: $id, $sys
	$errmsg = '';
	$sys  = $_SERVER['SERVER_NAME']; $sys=str_replace("www.","",$sys);
	$id   = $_SERVER['REMOTE_ADDR']; if ($_SERVER['REMOTE_HOST']!='') $id.=' '.$_SERVER['REMOTE_HOST'];
	$to   = $_REQUEST['to'];
	if ($to=='')
		{ $errmsg = "A destination address is required.<br>"; }
	else if (!stristr($to,$sys))
		{ $errmsg = "Invalid destination: ".$to."<br>Domain must be: ".$sys."<br>"; }
	$title = $_REQUEST['title'];
	$tags = $_REQUEST['tags'];
	$subj = $_REQUEST['subj'];
	$msg  = $_REQUEST['code'];
	
	// connect to references data base
$username="unigaiab_skyeriq";
$password="xcaan100";
$database="unigaiab_Courses";

	//put data into database
	
$createdby="skye";
$created= $_REQUEST['who'];
$type="video";
$url="blanck";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO references VALUES ('$title','$createdby','$created','$tags','$msg','$type','$url')";
mysql_query($query);

mysql_close();

?>
<center>
<table border=1 bgcolor=#ffffff cellspacing=0 cellpadding=2><tr><td>
	<font face="verdana,arial,helvetica" size=-2>
	<i>Titulo:</i> <?php echo $title ?> &lt;<?php echo $from ?>&gt; [IP: <?php echo $id ?>]<br>
	<i>TAGs:</i> <?php echo $tags ?><br>
	<i>SUBJECT:</i> <?php echo $subj ?><br>
	</font>
</td></tr><tr><td align=center>
	<font face="verdana,arial,helvetica" size=-2><b><?php
		if ($errmsg!="") echo $errmsg."Please try again.";
		else { // send message
		      mail($to,$subj,'[ Visitor IP: '.$id." ]\n\n".$title."\n".$tags." ".$createdby." ".$created." ".$url." ".$type."\n".$msg."\n\n From: <".$from.'>');
			echo "Thank you. Your message has been sent";
		}
	?><b></font>
</td></tr></table>
</center>

Initial URL


Initial Description
Vitor......porque esta codigo não funciona?

Initial Title
mySQL input and email

Initial Tags


Initial Language
PHP