email query
Posted: Thu Oct 26, 2006 8:51 pm
feyd | Please use
This is the processing script for the new user page:
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
This is just hard to explain. I'm coding a help desk. I have right now 4 different email meassages in my database. I would like to send out an email message automatically based on what the user does. For instance, If a new user would like to sign up I want to send out the email message in the database name user-new user signup.
So my thoughts were to include the variables from the form being submitted in the email messages that are located in the database. Pull the message out of the database and mail the message using PHPmail function in the processing script file.
That doesn't work. The delimna is to get the information from the form and put it in the email that's going to be sent out to the user.
If you can think of a better way to do this your help is greatly appreciated. Some code is below.
This is one of the messages in the database:Code: Select all
<?
mssql_query("INSERT INTO email(email_name, subject, email) VALUES ('User-New User Signup', 'Keiser Support - User Information',
'Thank you for signing up with Keiser Support. Please review your user information below: <br><br>
User Information: <br>
-----------------------------------<br>
User Name:'$e_user'<br>
First Name:'$first'<br>
Last Name:'$last'<br>
Email Address:'$email'<br>
Location:'$loc'<br>
Password:'$newpass'<br><br>
If any of your user information is incorrect you can log into Keiser Support and edit your account.<br>
Please do not respond to this email this is an unmonitored email address. Keep this information for your records.<br><br>
Regards,<br>
Keiser Support Team<br>')");
mssql_close($connect);
?>Code: Select all
<?include('config.php');?>
<?php
session_start();
//Next...Moving on to connecting to the database
$connect=mssql_connect($server, $username, $password);
mssql_select_db($db, $connect);
//assigning variables
$user=$_POST['name'];
$first=$_POST['fname'];
$last=$_POST['lname'];
$email=$_POST['email'];
$ph=$_POST['phone'];
$loc=$_POST['location'];
$newpass=$_POST['password'];
$connew=$_POST['con_pass'];
//error messages
if(strlen($user) == 0)
{
header("Location: http://webdemo/newusernameerr.html");
}
if(strlen($email) == 0)
{
header("Location: http://webdemo/newuseremailerr.html");
}
if(strlen($user)== 0 && strlen($email)==0)
{
header("Location: http://webdemo/newusercomberror.html");
}
//querying database
$sql="SELECT username
FROM info
WHERE username = '$user'";
$result = mssql_query($sql)
or die('result not added');
//inserting name, email, password, and location into the database if it's not already there
if(!mssql_num_rows($result) == $user)
{
//insert values into the database
$query = "INSERT INTO info (username, password, firstname, lastname, email, phone, location) VALUES ('$user', '$newpass', '$first', '$last', '$email', '$ph', '$loc')";
//add values to database by using mssql_query
mssql_query($query) or die('Error, insert query failed');
$sql="SELECT email FROM email WHERE id=1";
$result = mssql_query($sql)
or die('Query failed. ');
for ($i=0; $i < mssql_num_rows($result); $i++) {
$body=mssql_result($result,$i,"email");
}
$sql="SELECT subject FROM email WHERE id=0";
$result = mssql_query($sql)
or die('Query failed. ');
for ($i=0; $i < mssql_num_rows($result); $i++) {
$subject=mssql_result($result,$i,"subject");
}
//intializing session variable
foreach($HTTP_POST_VARS as $key=>$value)
{
$thisData[$key]=$value;
$_SESSION[$key]=$value;
}
//intializing mail varables
$to = stripslashes($_POST['email']);
$from ="KCSIT@Keisercollege.edu";
if(mail($to, $subject, $body, "From: $from")){
header("Location: http://webdemo/thankyou.php");}
else{ header("Location: http://webdemo/failedmailerr.html");}
}
else
{
header("Location: http://webdemo/user_nmerror.html");
}
mssql_close($connect);
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]