Jump to content

Multiple Form Actions


eskimowned

Recommended Posts

Excellent advice gents - I was hoping for a little more than "yes this can be done" :D.

I'll clarify it a little better, I was probably a little vague: all I want to do is when the submit button is clicked it inserts a record into the database and email some information. How can this be done.

Or would I do it by updating the database within the mail script the form action sends to.

Any help anyone can give me is always greatly appreciated.
Link to comment
Share on other sites

[code]<?php

$company = $_POST['Company'];
$first = $_POST['FirstName'];
$last = $_POST['LastName'];
$event = $_POST['Event'];
$price = $_POST['Price'];

// Grab our config settings
require_once($_SERVER['DOCUMENT_ROOT'].'/PHPdocs/phpmailer/config.php');

// Grab the FreakMailer class
require_once($_SERVER['DOCUMENT_ROOT'].'/PHPdocs/phpmailer/MailClass.inc');

// instantiate the class
$mailer = new FreakMailer();

// Set the subject
$mailer->Subject = 'This is a test';

$mailer->isHTML(true);

// Send the E-Mail
// Body
$mailer->Body = '<img src="http://www.womeninbusiness.co.uk/images/WIBsphere.jpg" alt="WIB logo" /><br />

<h2>WIB HTML test</h2>
<p>Visit us <a href="http://www.womeninbusiness.co.uk" title="Women In Business">Women In Business.co.uk</a> for a loving community!</p>
<?php "Dear ". $first. "<br/>";?>
<p>Sincerely,<br>
Shauns Web test </p>';

// Add an address to send to.
$mailer->AddAddress('shaun@designatedassociates.com', 'shaun');
$mailer->AddAddress('darren.wirth@designatedassociates.com', 'Darren');

if(!$mailer->Send())
{
  echo 'There was a problem sending this mail!';
}
else
{
  echo 'Mail sent!';
}
$mailer->ClearAddresses();
$mailer->ClearAttachments();
?>
[/code]

The bit I can't get to display is the <?php "Dear ". $first. "<br/>";?>

Any ideas?
Any help is always greatly appreciated
Link to comment
Share on other sites

[code]<?php require_once('../../Connections/Conn1.php'); ?>
<?php
mysql_select_db($database_Conn1, $Conn1);
$query_UpdateCustInfo = "SELECT * FROM Customer";
$UpdateCustInfo = mysql_query($query_UpdateCustInfo, $Conn1) or die(mysql_error());
$row_UpdateCustInfo = mysql_fetch_assoc($UpdateCustInfo);
$totalRows_UpdateCustInfo = mysql_num_rows($UpdateCustInfo);

$company = $_POST['Company'];
$first = $_POST['FirstName'];
$last = $_POST['LastName'];
$event = $_POST['Event'];
$price = $_POST['Price'];

mysql_query("INSERT INTO CUSTOMER (Company, `First Name`, `Last Name`, Event, price) VALUES ('$Company', '$first', '$last', '$event', '$price')");
mysql_close();

// Grab our config settings
require_once($_SERVER['DOCUMENT_ROOT'].'/PHPdocs/phpmailer/config.php');

// Grab the FreakMailer class
require_once($_SERVER['DOCUMENT_ROOT'].'/PHPdocs/phpmailer/MailClass.inc');

// instantiate the class
$mailer = new FreakMailer();

// Set the subject
$mailer->Subject = 'This is a test';

$mailer->isHTML(true);

// Send the E-Mail
// Body
$mailer->Body = '<img src="http://www.womeninbusiness.co.uk/images/WIBsphere.jpg" alt="WIB logo" /><br />

<h2>WIB HTML test</h2>
<p>Visit us <a href="http://www.womeninbusiness.co.uk" title="Women In Business">Women In Business.co.uk</a> for a loving community!</p>
<?php "Dear ". $first. "<br/>";?>

<p>Sincerely,<br>
Shauns Web test </p>';

// Add an address to send to.
$mailer->AddAddress('shaun@designatedassociates.com', 'shaun');
$mailer->AddAddress('darren.wirth@designatedassociates.com', 'Darren');

if(!$mailer->Send())
{
  echo 'There was a problem sending this mail!';
}
else
{
  echo 'Mail sent!';
}
$mailer->ClearAddresses();
$mailer->ClearAttachments();
?>
<?php
mysql_free_result($UpdateCustInfo);
?>
[/code]

I've also included a copy of the code to show the update record query, thats not working either, DOH!

Any help anyone can give me on that as well would be awesome. Cheers everyone!
Link to comment
Share on other sites

That worked - you are a legend! Thanks to everyone who gave me suggestions, this is a bit of a learning curve for me, so all of your advice is greatly appreciated.

Now I know I'm pushing my luck here - but has anyone any ideas why the insert record query at the top isn't doin anything?

Cheers

Liverpool Eskimo
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.