Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
What do I need to add to either a .php or .asp file to make it act as a formmail???
Old 11-12-2003, 11:06 AM What do I need to add to either a .php or .asp file to make it act as a formmail???
Phunky's Avatar
Skilled Talker

Posts: 68
Location: NJ
Trades: 0
I am trying to rearrange some form results so that they can be show using HTML/CSS and I think i now know how to do it (or pretty close to it) using .php or .asp (i have never worked with .php and only a tiny bit with .asp, so I am not 100% on either's syntax, but the large problem is that the .php or .asp file must replace the action of the form (which formerly contained my formmail.cgi file!)

So I am looking for some kind of code I can add to either a .php or .asp page to make it act as a formmail....

Does anybody know anything about this???


*btw, i am on an eMac and use dreamweaver, but that is mostly because I don't have a better html editer, i like to work in the code myself...
__________________
But dreaming just comes natural
Like the first breath from a baby,
Like sunshine feeding daisies,
Like the love hidden deep in your heart.

~J.Prine
Phunky is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-15-2003, 09:52 PM
EvilHaider's Avatar
Skilled Talker

Posts: 56
Trades: 0
For a formmail script you dont need anything more than a simple text editor.

You can visit hotscripts.com and they have TONS of form-to-email scripts in both ASP and PHP. Most of these are very easy to setup. You can download any of them and use them in your site.
EvilHaider is offline
Reply With Quote
View Public Profile
 
Old 11-16-2003, 06:20 PM
Experienced Talker

Posts: 31
Location: Redondo Beach, CA
Trades: 0
I work mostly by myself so I'm not up on the lingo. By 'formmail' I presume you mean an HTML form that when submitted causes an email to be sent.

I mainly use php, but it is virtually the same for asp.

The form will just be html (could be in a .php file or .html or .htm file), but the action will be to a php page. Like so:

<form action=phppage.php method=post>
<input type=text name=email><br>
<input type=text name=subject><br>
<input type=text name=message><br>
<input type=submit value=Submit>
</form>

The php page (in this case phppage.php) will be like this:

<?php
mail($email, $subject, $message);
echo 'Your mail has been sent.';
?>

There are other options. For details on the mail function visit www.php.net. This will require that your server is configured to send mail.
__________________
Myrealtypage - Real Estate Web Design
myrealtypage is offline
Reply With Quote
View Public Profile Visit myrealtypage's homepage!
 
Old 11-17-2003, 01:11 PM
Phunky's Avatar
Skilled Talker

Posts: 68
Location: NJ
Trades: 0
thanks a lot folks, i had forgot i had asked this here...

i actually found out about this mail () function last week and have been very happy with it...


if you set up a variable in the php code, you can add HTML to the message...

for example:

Quote:
<?php

$message_body = "<STYLE type='text/css'>.class { font-family: Verdana, Helvetica, Sans-Serif; font-size:12px; font-weight:bold; font-style:normal; color:#4A207E; background:none; } </STYLE>
<div align='center'>Online Application Received from <span class='class'>$last_name, $first_name</span></div>"

mail($email, $subject, $message_body);
echo 'Your mail has been sent.';

?>
what I am still having trouble with however is setting required fields...

I have tried different code, but cant get it to work at all...
__________________
But dreaming just comes natural
Like the first breath from a baby,
Like sunshine feeding daisies,
Like the love hidden deep in your heart.

~J.Prine
Phunky is offline
Reply With Quote
View Public Profile
 
Old 11-17-2003, 01:51 PM
Experienced Talker

Posts: 31
Location: Redondo Beach, CA
Trades: 0
Sorry, which required fields do you mean?

If you are receiving $message_body from a POST or a GET, you will be overwriting it when you set $message_body in your script.

To prepend what you wrote to the $message_body variable do this:

$message_body = "whateveryouwant" . $message_body;

If that was not your problem let me know.
__________________
Myrealtypage - Real Estate Web Design
myrealtypage is offline
Reply With Quote
View Public Profile Visit myrealtypage's homepage!
 
Old 11-17-2003, 02:01 PM
Phunky's Avatar
Skilled Talker

Posts: 68
Location: NJ
Trades: 0
right, that is not the problem...

before i could use the

<input type=hidden name=required value='first_name, last_name ,email, address, city, state, zip'>


but i cannot do that with the php script I have... i need to figure out how to require that certain fields are filled in...
__________________
But dreaming just comes natural
Like the first breath from a baby,
Like sunshine feeding daisies,
Like the love hidden deep in your heart.

~J.Prine
Phunky is offline
Reply With Quote
View Public Profile
 
Old 11-17-2003, 02:17 PM
Experienced Talker

Posts: 31
Location: Redondo Beach, CA
Trades: 0
Something a little like this:

have the form, validation and processing all on the same page and submit to that page.

file = emailprocessor.php

<?php
$valid = TRUE;
if ($submitted) { // it was submitted
if ($email && $firstname && $whateverisrequired) {
// all required fields are there (if 0 is ok for an entry you need to use isset($variable) instead of just the variable itself
// now construct your message
mail($email, $subject, $message);
echo "thanks";
}
else { // something was missing
$valid = FALSE;
}
}
if ($valid == FALSE) {
echo "something was missing";
}
if (!$submitted || !$valid) {
echo '<form action=emailprocessor.php method=post>';
echo 'First Name <input type=text name=firstname>';
//and the rest of the HTML for the form
echo '<input type=hidden name=submitted value=1>';
}

?>

I have a function/object that does more like validates numbers, dates, addresses, dollar amounts, etc and highlights the form elements that were invalid, but that is a bit much to get into in the post. If you are interested you can email me off the list at jay@myrealtypage.com
__________________
Myrealtypage - Real Estate Web Design
myrealtypage is offline
Reply With Quote
View Public Profile Visit myrealtypage's homepage!
 
Old 11-17-2003, 02:54 PM
Phunky's Avatar
Skilled Talker

Posts: 68
Location: NJ
Trades: 0
Thanks a lot!!! That looks like it may be just what I am looking for... Think its time for a lunch break and then I'll try to implement it... I really do appriciate the help, thanks!

-Pat
__________________
But dreaming just comes natural
Like the first breath from a baby,
Like sunshine feeding daisies,
Like the love hidden deep in your heart.

~J.Prine
Phunky is offline
Reply With Quote
View Public Profile
 
Old 11-18-2003, 12:09 PM
Phunky's Avatar
Skilled Talker

Posts: 68
Location: NJ
Trades: 0
Quote:
Originally posted by myrealtypage
Something a little like this:

have the form, validation and processing all on the same page and submit to that page.

file = emailprocessor.php

<?php
$valid = TRUE;
if ($submitted) { // it was submitted
if ($email && $firstname && $whateverisrequired) {
// all required fields are there (if 0 is ok for an entry you need to use isset($variable) instead of just the variable itself
// now construct your message
mail($email, $subject, $message);
echo "thanks";
}
else { // something was missing
$valid = FALSE;
}
}
if ($valid == FALSE) {
echo "something was missing";
}
if (!$submitted || !$valid) {
echo '<form action=emailprocessor.php method=post>';
echo 'First Name <input type=text name=firstname>';
//and the rest of the HTML for the form
echo '<input type=hidden name=submitted value=1>';
}

?>

I tried to install this on my page but got very confused in the process...

I have a php page set up (the results of an HTML Application form page) already which sends the results in an HTML email to the person who filled out the application and one to the company... This page also pops up a new window which displays the results of the form submission...

What i am most confused about above is why you were echoing input fields, where $submitted and $valid came from, and nesting of your if/else statements... plus I just cant see how I can get this to work on my page...

if it helps at all, the page I am working on is
APPLICATION FORM
the corresponding .php page is at appResults.php
__________________
But dreaming just comes natural
Like the first breath from a baby,
Like sunshine feeding daisies,
Like the love hidden deep in your heart.

~J.Prine
Phunky is offline
Reply With Quote
View Public Profile
 
Old 11-18-2003, 01:39 PM
Experienced Talker

Posts: 31
Location: Redondo Beach, CA
Trades: 0
"why you were echoing input fields"
inside php tags that is how you output html, so you can either
<?php
// some php
echo 'whatever';
// more php
?>
or you can
<?php
// some php
?>
whatever
<?php
// more php
?>
If it is a long section of just echoing straight HTML I will close the php and echo it, but for short sections it is just easier to read if you echo the HTML from inside the php tags.

"where $submitted and $valid came from"
If the user visits the page for the first time there will be a form displayed, which will include the hidden tag named 'submitted'.
If they submit the form they will still be on the same page, but $submitted will equal 1.

$valid is set to be TRUE at first and then if $submitted exists the validation happens (just making sure whatever variables you wanted were filled out in the form (and are not just spaces or 0 - use isset if those values are ok). If values are not there set $valid to FALSE and if that is the case the form will be displayed again.

Now, this example is for a page that submits to itself. Your site does not have the page submitting to itself. You have two options in this case.

1. Use Javascript to make sure the required fields are filled out. Then when they click submit it will just pop-up an alert saying that some required fields are missing. To do this the submit button will run a javascript function with the onClick event.

2. On the php page check that the required fields have been completed. If they have, send the email(s). If they have not, because you are poping the processing page up in a different window, you can just echo a message that whatever fields were missing they can close this window and finish. If you want to be fancy you can have php echo some javascript that will pop up an alert with the message and close the processing page's window automagically.

I'd go with option 1.
__________________
Myrealtypage - Real Estate Web Design
myrealtypage is offline
Reply With Quote
View Public Profile Visit myrealtypage's homepage!
 
Old 11-18-2003, 01:42 PM
Experienced Talker

Posts: 31
Location: Redondo Beach, CA
Trades: 0
Sorry the english wasn't too good on that post.

"Me fail English, that's unpossible." - Ralph Wiggum
__________________
Myrealtypage - Real Estate Web Design
myrealtypage is offline
Reply With Quote
View Public Profile Visit myrealtypage's homepage!
 
Old 11-18-2003, 04:08 PM
Phunky's Avatar
Skilled Talker

Posts: 68
Location: NJ
Trades: 0
:lol:


thanks a lot for taking the time to write all that, I am new to php so I was not following everything 100%... I think you are right about option # 1... I gotta go on my laptop and find some old scripting where I did that same thing I do believe...




I gotta say though... besides the few places where I am getting really stuck, php is freaking FANTASTIC! I love it!
__________________
But dreaming just comes natural
Like the first breath from a baby,
Like sunshine feeding daisies,
Like the love hidden deep in your heart.

~J.Prine
Phunky is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to What do I need to add to either a .php or .asp file to make it act as a formmail???
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43544 seconds with 12 queries