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.

PHP Forum


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



Freelance Jobs

Reply
PHP Form to send messages and add elements to database
Old 11-16-2010, 05:07 PM PHP Form to send messages and add elements to database
Junior Talker

Posts: 1
Trades: 0
Hi,

I am trying to implement a custom form to poll.

The people visiting our website would write the name of famous persons.

The form would send the name to an e-mail address, and would also send them to a database implemented with a single purpose: serving as a filter for other people not to send the names already sent and added to the database.

The idea seems to be simple; the problem is that I am just a web designer with a modest knowledge of programming (Oscommerce and other online shops, and certain activity with databases).

I have already installed a MySQL database, but I have no idea what might be the next step, the code to insert in the form or in the database, and I would be really thankful to receive some advice or help in this issue.

Thanks for your replies.



andrewakenton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-16-2010, 08:19 PM Re: PHP Form to send messages and add elements to database
Average Talker

Posts: 25
Name: Stephen
Location: Arizona
Trades: 0
I recommend going to w3schools.com and look at some of their tutorials for html, css, php, and mysql.
__________________

Please login or register to view this content. Registration is FREE
and
Please login or register to view this content. Registration is FREE
GetGamesHere is offline
Reply With Quote
View Public Profile Visit GetGamesHere's homepage!
 
Old 11-17-2010, 07:14 AM Re: PHP Form to send messages and add elements to database
Gakoyu Ojima's Avatar
Skilled Talker

Posts: 59
Location: Netherlands.
Trades: 0
PHP forms are actually pretty simple. You'll only need two files: one php file (doesn't have to be, but preferred personally) for the form, and a php file to process the information and send the e-mail.

In your first *.php or *.html file, you'll write the form in html, obviously.

HTML Code:
<form method="post" action="urlscript.php">
    <span>Your Name</span>: <input type="text" name="realname" size="30" maxlength="50" /><br />
    <span>Your E-Mail</span>: <input type="text" name="useremail" size="30" maxlength="100" /><br />
    <span>Your Celebrity Entries:</span>:<br />
    <textarea name="entries" rows="20" cols="40">
    
    </textarea><br />
    <input type="submit" name="submit" value="submit" />
</form>
'action="urlscript.php"' is the location where the information will be processed. Rename it accordingly to that of your file which processes the information.

In the file you inserted in the action attribute, you'll need to process said information, and let the users send an e-mail to yours after clicking submit.

PHP Code:
<?php
$realname 
$_REQUEST['realname'];
$useremail $_REQUEST['useremail'];
$entries $_REQUEST['entries'];

mail('gakoyu@test.com''Celebrity Names - by '.$realname.''$entries'From: '.$useremail);
?>
As you can see, I've assigned variables to the named input types (being "realname", etcetera). These variables can then be used for the mail function.

mail() needs several parameters, and several additional ones can be added too, if wished. In this case, we give the following parameters: the mail to which it needs to be sent, the subject of the e-mail, the message/body, and an additional parameter that shows from who the e-mail comes ($useremail)..

You can also add a header() function to the top of the document, as that will redirect the user to a new page instead of remaining a blank one.

Oh, also make sure you change the e-mail in the PHP code above; it's merely a random email I've used which is not the one you need, obviously.

That's it.
__________________
$gocore = new gakoyucore();
$con = mysql_connect($gocore->server, $gocore->username, $gocore->password) or die(mysql_error());

Last edited by Gakoyu Ojima; 11-17-2010 at 07:20 AM..
Gakoyu Ojima is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Form to send messages and add elements to database
 

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.58070 seconds with 12 queries