PHP Send to Phone/E-Mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeffyyy
Forum Newbie
Posts: 17
Joined: Sat Apr 24, 2010 9:06 pm

PHP Send to Phone/E-Mail

Post 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)
?> 
Last edited by jeffyyy on Mon Apr 26, 2010 6:47 pm, edited 1 time in total.
davex
Forum Contributor
Posts: 101
Joined: Sat Feb 27, 2010 4:10 pm
Location: Namibia

Re: PHP Send to Phone/E-Mail

Post by davex »

Hi,

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

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

Cheers,

Dave.
jeffyyy
Forum Newbie
Posts: 17
Joined: Sat Apr 24, 2010 9:06 pm

Re: PHP Send to Phone/E-Mail

Post 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.
Post Reply