mySQL input and email


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. <?php
  2. // inputs: $to, $title, $tags, $subj, $code
  3. // computed: $id, $sys
  4. $errmsg = '';
  5. $sys = $_SERVER['SERVER_NAME']; $sys=str_replace("www.","",$sys);
  6. $id = $_SERVER['REMOTE_ADDR']; if ($_SERVER['REMOTE_HOST']!='') $id.=' '.$_SERVER['REMOTE_HOST'];
  7. $to = $_REQUEST['to'];
  8. if ($to=='')
  9. { $errmsg = "A destination address is required.<br>"; }
  10. else if (!stristr($to,$sys))
  11. { $errmsg = "Invalid destination: ".$to."<br>Domain must be: ".$sys."<br>"; }
  12. $title = $_REQUEST['title'];
  13. $tags = $_REQUEST['tags'];
  14. $subj = $_REQUEST['subj'];
  15. $msg = $_REQUEST['code'];
  16.  
  17. // connect to references data base
  18. $username="";
  19. $password="";
  20. $database="";
  21.  
  22. //put data into database
  23.  
  24. $createdby="skye";
  25. $created= $_REQUEST['who'];
  26. $type="video";
  27. $url="blanck";
  28.  
  29. mysql_connect(localhost,$username,$password);
  30. @mysql_select_db($database) or die( "Unable to select database");
  31.  
  32. $query = "INSERT INTO references VALUES ('$title','$createdby','$created','$tags','$msg','$type','$url')";
  33. mysql_query($query);
  34.  
  35.  
  36. ?>
  37. <center>
  38. <table border=1 bgcolor=#ffffff cellspacing=0 cellpadding=2><tr><td>
  39. <font face="verdana,arial,helvetica" size=-2>
  40. <i>Titulo:</i> <?php echo $title ?> &lt;<?php echo $from ?>&gt; [IP: <?php echo $id ?>]<br>
  41. <i>TAGs:</i> <?php echo $tags ?><br>
  42. <i>SUBJECT:</i> <?php echo $subj ?><br>
  43. </font>
  44. </td></tr><tr><td align=center>
  45. <font face="verdana,arial,helvetica" size=-2><b><?php
  46. if ($errmsg!="") echo $errmsg."Please try again.";
  47. else { // send message
  48. mail($to,$subj,'[ Visitor IP: '.$id." ]\n\n".$title."\n".$tags." ".$createdby." ".$created." ".$url." ".$type."\n".$msg."\n\n From: <".$from.'>');
  49. echo "Thank you. Your message has been sent";
  50. }
  51. ?><b></font>
  52. </td></tr></table>
  53. </center>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.