Jump to content

Probs running email notifier and reg.php on same script


ruuyx

Recommended Posts

I edited a script that lets me know if a new user has registered on my web page by php sending me an email notification. When i inserted this script into the same script that submits the form the new user filled out "contactus.php...only the newusernotification.php works. When i shift the contactus.php script before the newusernotification script....the contactus runs and submits all data into mySQL table created for it.

 

How can i get the two form actions to submit data into the table for new user contacts and at the same time send me an email notification

 

contactus.php

 

<?php

 

include "config2.php" ;

 

// connect to the mysql server

$link = mysql_connect($server, $db_user, $db_pass)

or die ("Could not connect to mysql because ".mysql_error());

 

// select the database

mysql_select_db($database)

or die ("Could not select database because ".mysql_error());

 

 

// insert the data

$query = "insert into $table values ('".$_POST['contact_name']."', '".$_POST['address']."', '".$_POST['address2']."', '".$_POST['city']."', '".$_POST['state']."', '".$_POST['zip']."', '".$_POST['country']."', '".$_POST['phone']."', '".$_POST['email']."', '".$_POST['r_message']."')";

$result = mysql_query($query) or die("error: ". mysql_error(). " with query ". $query);

 

// print a success message

echo "Your Message Has Been Sent!

";

echo "Now you can <a href=index.htm>return to Our Homepage[/url]";

 

newusernotification.php

<?php

$to = "[email protected]"; // The email address you want the notification sent to

$subject = "A New Member has registered - check Pending Profiles"; // What do you want the subject line of your notification to be?

$memberSpecs =

"<hr size=2 width=300 align=left>".

"Username: ".$_SESSION['username'].

"

".

"Real Name: ".$_SESSION['firstname']. " ".$_SESSION['lastname'].

"

".

"IP address: ".$_SERVER['REMOTE_ADDR'].

"

".

"Date & Time: " .date('l, F j, Y, g:i:s a').

"

".

"System Specs: ".$_SERVER['HTTP_USER_AGENT'].

"

";

$headers = "Content-type: text/html \nFrom: New Member Notification";

$body = "<body>

 

 

<table cellspacing=1 cellpadding=2 align=center>

<tr>

<td>

<font face=arial size=2>A New Member has registered. </font>

<font face=arial size=2>Member's Username, Real Name, IP address and System Specs:</font>

</td></tr>

<tr>

<td>

<font face=arial size=2> ".$memberSpecs." </font>

</td></tr></table>

</body>";

mail("$to", "$subject", "$body", "$headers");

 

// print a success message

echo "Your Contact Information Has Been Sent!

";

echo "Now you can <a href=index.htm>return to Our Homepage[/url]";

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.