Page 1 of 1

PHP Send to Phone/E-Mail

Posted: Sun Apr 25, 2010 10:00 am
by jeffyyy
OK, so I have a script that lets users leave a message for somebody and that person would have to go to the site, type in their "tag" and see any messages left for them. IS it possible for them to be able to signup and leave a cell phone number, then when a message is sent to their "tag" they would receive a copy of the message via e-mail or sms?? Help would be greatly appreciated!!!! I have posted my code below:

form to send message

Code: Select all

<form action="insert.php" method="post">
	<fieldset>
		<label>License Plate:</label><input type="text" name="tag" />
		<label>Message:</label><textarea name="message" cols="55" rows="8"></textarea>
		<input type="submit" name="Send" value="Send" />
    </fieldset>
</form>
php code to actually insert the message into database

Code: Select all

<?php
$con = mysql_connect("localhost","text_tag","db_pass);
$tm=time();
$ref=@$HTTP_REFERER;
$agent=@$HTTP_USER_AGENT;
$ip=@$REMOTE_ADDR;
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("text_tag", $con);

$sql="INSERT INTO testtable (tag, message, tm, ref, agent, ip, tracking_page_name)
VALUES
('$_POST[tag]','$_POST[message]','$tm', '$ref', '$agent', '$ip', '$tracking_page_name')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Your message has been sent";

mysql_close($con)
?> 

Re: PHP Send to Phone/E-Mail

Posted: Sun Apr 25, 2010 11:31 am
by davex
Hi,

Yes it's very simple to send mail in PHP:

http://www.php.net/manual/en/function.mail.php

Cheers,

Dave.

Re: PHP Send to Phone/E-Mail

Posted: Sun Apr 25, 2010 11:44 am
by jeffyyy
Yes, I know how to send mail in PHP, but I was hoping for some help with this:

When use sends message, it creates the row in the database but it also checks if a user with that "tag" exists and if they do, it sends it to the email address of the person with that tag.