Jump to content


Photo

Multiple Form Actions


  • Please log in to reply
21 replies to this topic

#1 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 20 September 2006 - 02:47 PM

Is it possible to have multiple form actions.

I want to use a form to update to MYSQL database and mail information, once the submit button is pressed. Is this possible?


#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 September 2006 - 03:39 PM

You can't have multiple actions, but you do not need that for updating database entries and mail info.

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 20 September 2006 - 03:43 PM

Why cant you do both the database update and the mail action on the same page...?

Orio.
Think you're smarty?

(Gone until 20 to November)

#4 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 20 September 2006 - 08:05 PM

you could...

#5 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 21 September 2006 - 07:27 AM

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.

#6 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 21 September 2006 - 07:30 AM

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

exactly.  you can do as many operations as you'd like on the action page; i'd suggest updating the database first, and then mailing the information.

#7 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 21 September 2006 - 11:32 AM

Quality - Cheers geezer!

I think I know how to get that to work.

Just a quick question about the mail form - using PHPmailer how do you show form vairiables as part of the HTML body?

Any help on that would be sweet.

Cheers in advance.  PEACE

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 September 2006 - 11:39 AM

$message = "Dear ". $yourname. "<br/>";
$message.= "Thanks very much for the order for ". $widget. ". We know you'll enjoy it.<br/>";
$message.= "Yours insincerely, blah blah";

Legend has it that reading the manual never killed anyone.
My site

#9 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 21 September 2006 - 01:14 PM

<?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(); 
?> 

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

Any ideas?
Any help is always greatly appreciated

#10 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 21 September 2006 - 01:45 PM

<?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);
?>

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!

#11 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 22 September 2006 - 12:09 AM

can anyone help? It would be muchos appreciated.

#12 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 22 September 2006 - 12:20 AM

Hej,
In regards to the "Dear.."; not printing.
replace

<?php "Dear ". $first. "<br/>";?>

with

<?php echo"Dear ". $first. "<br/>";?>



#13 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 22 September 2006 - 10:04 AM

I've just done the suggested change and this is what comes out in the email:

WIB HTML test
Visit us Women In Business.co.uk for a loving community!

";?>
Sincerely,
Shauns Web test

DOH!

Any sugggestions would be greatly appreciated.

Peace

#14 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 22 September 2006 - 12:53 PM

Please help - I'm so stuck! Apologies if this appears to be a noobish question.

#15 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 22 September 2006 - 04:12 PM

bttt

#16 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 23 September 2006 - 03:02 AM

<?php echo"Dear ". $first. "
";?>

should have been

<?php echo"Dear $first" ?>


#17 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 25 September 2006 - 07:38 AM

Cheers for the help, I made the suggested change but this time nothing happened, the email came through but the php variable didn't come through. doh!

I still cant get it to update the table either.

Sorry to be a pain, but if anyone can shed any light on this it would be quality.

#18 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 26 September 2006 - 01:30 AM

Hej
  I suggest you check that the 'first name' field on the form that sends to your script is spelt right.

WW.

#19 eskimowned

eskimowned
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 26 September 2006 - 07:30 AM

It is spelt right, just checked and double checked. If it had been that I would have been very upset.

Still no joy I'm afraid. I'm assuming it must be something to do with PHPmailer.

I'm getting so frustrated with this.



#20 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 26 September 2006 - 07:37 AM

Hi,

Its simple. Your making the mail into the $mailer->Body so all behind the = sign must be in either ' and end in ' or " and end in ". So when you want to add the Dear at the end you should get ride of the <?php sign and the " and have something like this.

</p>Dear '. $first. '<br/>';






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users