Jul 27, 2008

Help With Some Website Coding - Databases and saving form results

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Help With Some Website Coding - Databases and saving form results

PlugComputers
Hey all,

I was looking for some help with creating my new website. I have a form already created, with some text areas, checkboxes, drop down menu's, ect. I need some help setting up the code to save the form data once the user clicks "Submit" after filling in their information in the form.

I was hoping to do this 2 ways - 1. Saving the information into some type of database (MySQL I'm guessing?) and 2. Have the form results emailed to me.

I am familiar with the old way of emailing the results by putting "mailto:email@domain.com" into the form, but new browsers block against this, making it kind of a "shady" way of emailing the results in my opinion.

Please help me, I need help coding it, and figuring out how to set up the database to accept the information from the form.

Thanks again.

Reply

Tsunami
well you could do what i would do and is use php and put all the contents in a text file and then write ANOTHER form just for you so you can read the information nice and orderly... or you could do this to make it email to you....

change the opening form tag to this:
CODE
<form action="formprocess.php" method="POST">


then create a php file called formprocess.php and put this in it:

CODE

<?
$myemail = "youremail@host.com";

$numoffields = "2";
//YOU MUST CHANGE THIS

$formn[0] = "What form 1 is called";
$form[0] = $_POST['fieldname'];
//field name is found in <input name=FIELDNAME>

$formn[1] = "What form 2 is called";
$form2[1] = $_POST['fieldname'];

$message ="";
for($i = 0; $i < $numoffields; $i++)
$message .= $formn[$i] . " --- " . $form[$i] . "<br>";

mail($myemail,"FORM RESULTS",$message);
?>


its commented so you know what to do... just copy and paste this:
CODE

$formn[0] = "What form 1 is called";
$form[0] = $_POST['fieldname'];


to where the other ones are and change the numbers accordingly

 

 

 


Reply

vujsa
You might want to get a prewritten script to help with your forms.

Check out http://php.resourceindex.com

They have listings for hundreds of scripts one of which will probably help you!

Reply

matak
a question to tsunami
well i haven't googled this but i think you might already know it and the answer from you is much simpler then looking for some code on 20 pages smile.gif
the question is this..
how to create the most simplest form that connects with a database?
lets say you just have
'Name'
'Text'
and then something to display that information when asked (how to ask)?
Well i'll be thankfull even if u just post a good link to some simple code smile.gif

Reply

jlhaslip
download here
QUOTE

Readme.txt for the contact.php file
++++++++++++++++++++++

This file contains the information required to set up and operate the contact.php script on your Web Host. Php capability is required for this script and the Php mail function must be available for the script to work as described. Even without the full use of the mail function, the data will be written to the message_data.txt file, so it is handier than it looks, even if you don't have full features available on your site.

There is also the option of displaying messages onto your site as a sort of 'Guest Book'.

The script is not 'independent'. The script must be added to a valid html page with a doctype, head tags, body tags, etc for this to be properly set-up. Or 'included' onto a php page which already contains the required tags.


Instructions
++++++++++++

1.) Use Winzip (or whatever you have) to unpack the zip files into a folder on your computer. (Kinda redundant, because you have already done that or you wouldn't be reading this file)

2.) Edit the file (contact.php) and change the following to better reflect your site requirements:
// site email
$site_email = 'someone@example.com';
// name of the site
$site_name = 'This Site Name';
// subject of emails as sent to the site-email
$site_subject = 'Message from Contact Form ';
// used to flag printing email messages below contact form
$show_comments = 'true';
// used to flag printing of site_email address on the message listing
$show_site_email = 'true';
// used to flag printing of site_name on the message listing
$show_site_name = 'true';
// name of the file where the messages are stored
$file_name = "message_data.txt";
// be sure to chmod the file to '666' (write enabled by all)
// only need to do the chmod if the error shows on a test run
$show_IP = '0'; // change this value to 1 to (show) the IP's on the displayed output
// default is $show_IP = '0' to (hide) the IP's

3.) Upload these files (contact.php and message_list.php) to your web server and place it into the directory which contains the file which calls the script. Typically, this would be "/public_html".

4.) set a link to this file from the other pages on your site. An example for the coding would be: <a href="contact.php" title="Use this page to send us an Email"> Email Us </a>

5.) Change the permissions for the "message_data.txt" file to "0666" to allow it to be written to. For a Windows Server, this step is not required. Enter a Sample Email and you will see an error message if this needs to be done for your Hosting Service.

When someone enters Form data, the script will store the information in the "message_data.txt" file and send you an email using the php mail() script. It requires all parts of the form to contain data, ie: first_name, last_name, email in a valid format, and a message body. The IP Address is gathered by the Server and it is also available to you. See below.

I have tested this using Mozilla, Opera and IE5.5, so it should work on pretty much any Browser. It works with the css shut-off, too. As for Hosts, I have it set-up on a Host using php 4.4.1 and php 5.0 both, so it should be good on most Hosting Services.

At present, the only way to access the data in the message.txt file is to reference it directly using an URL something like this:

"http://www.site_name.Host_name.com/message_data.txt" where site_name and Host_name match yours,

or by running the script to display the messages as follows:

"http://www.site_name.Host_name.com/message_list.php". (ditto)(Assuming the file is in the public_html Directory.)

In order to have access to the IP Address information, you either must change the value of the $show_IP variable before you run the script, (see item #2 above) (then change it back so it won't display on the Guest Book), or use the first option (http://www.site_name.Host_name.com/message_data.txt) to look at the file without the benefit of formatting or the Table Structure. Either way, I assure you the information will be there for you.


And if you have any difficulties with installing this script, just drop me a PM.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : website, coding, databases, saving, form, results

  1. Coding Help!
    Need Tutorial?! (3)
  2. What Coding Languages Are Required?
    (5)
    I want to add a feature in my website so that users can make a professional -looking resume-like web
    page. It will be like a form based series of questions that visitor ll need to answer.Based on this
    a webpage as prescribed in pre-defined template ll be created .I want to know to do this what
    languages are used? I want some suggestion regarding this.My site is currently on Joomla platform.
    thanks in advance....
  3. Creating A Login Box That Links To My Phpbb Forum
    Have my phpBB Forum Intergrated with my Website (4)
    Can someone please give me a code that I can use to put a login box on my website, that will login a
    user into my phpBB Forum? Sort of like Having my phpBB Forum Intergrated with my Website? Thank you
    so much if you can! /angel.gif" style="vertical-align:middle" emoid=":angel:" border="0"
    alt="angel.gif" /> Ex. ....
  4. Help With Coding!
    please anybody help me! (2)
    Hi all..(if this is in bad section then sorry) I have one big problem with my site and I don't
    know how I can repair it. I have auto refreshed Shout box at site but there is little problem!
    When this shout box is accessed for guest there are coming spam bots and just spamming it. I know
    how to do it but I don't know about php. I have code for make this shout box Spam protected, but
    I dont know how to do it. All time when I add this code to php file, there is all things okey but
    auto refresh is not working /sad.gif" style="vertical-align:middle" emoid=":(" bo....
  5. To Search Within Search Results
    To search within search results (0)
    Is there a good and efficient way of searching within previously searched records using PHP/MySql? I
    tried searching on google with several keywords like nested search, search within results, recursive
    search with PHP and MySql, haven't got a clue so far yet. But I thought it might be just storing
    previously queried sql statements and to a select on it each time the search button is called? Any
    ideas?....
  6. New Found Php Coding Errors
    I always thought these worked, but suddenly they no longer do?! (5)
    Hi i'm dan from new zealand, right next to my home land australia. I have been writing php
    scripts for two years now and just recently none of them have been working. Please help me out as
    best as you can, i'm sure it is only something simple. CODE ----------------Form
    1-------------------------- <?php // ---- Customized form script for the HBRC---------------
    // Receiving variables ----------------------------------- @$fn =
    addslashes($_POST['fn']); @$ln =
    addslashes($_POST['ln']); @....
  7. <?php ?> Get Search Results To Your Localhost
    Simple way to get 100 results without allowing cookies (2)
    Ultimately simple script that allows you getting google search results to your localhost. This is
    the first part of the Crawler script i'm developing, and if you are interested in developing the
    script with me, IM me @icq328866661@msn/evil_matak/ a \hotmail-com. Here's the form
    part... QUOTE search.php QUOTE if (@$_POST ==""){ echo "What are you
    doing?"; } else{ $query =
    file_get_contents("http://www.google.com/search?q=".urlencode($_POST
    )."&num=100&hl=en&ie=UTF-8&filter=2"); //needs to be added with more queries �....
  8. Php Frameworks - Leaner, More Efficient Coding.
    A quick overview of what they are and where you can find some. (1)
    PHP Frameworks What do you guys think of coding websites using framworks like Zend or CakePHP? I
    used to code my applications from scratch but it does get tedious and because PHP is not as
    structured as other languages it's very easy to create redundant, unmaintainable code. I think
    a framework should be more than just a bunch of libraries. It's true that having libraries for
    functions specific to what you are trying to do might help alot but it takes more than that to
    create some maintainable code. What I' m talking about is MVC and Front Controllers. The....
  9. Help With Moving Html Form Results To Shopping Cart?
    (3)
    Hello All- So I think I'm tackling a pretty big project here and was looking for some help... I
    am fairly new to extensive coding (beyond HTML and a little bit of JavaScript) and wanted to know
    how I can recall HTML form results on the next page (in a shopping cart) with a price based on the
    choices picked in the form. It sounds complicated...look at this example: Check out this page:
    http://www.plugcomputers.com/intelprobuild.php See how when the user goes through and picks all
    their computer parts a price at the bottom shows the system price based on their sel....
  10. How To Group Mysql Results In A List
    (1)
    Ok so I have an array that I would like to group by date. When I use the group by in a mysql query
    it only shows one record with that value. However I want to show all the records grouped by date.
    This is what I have so far.


    CODE $completedprojectsresults=mysql_query(&#....
  11. Updating Website From Another -- Website
    Is it possible, and how? (7)
    i was just thinking about this project that i'm doing, and i thought that it would be a good
    thing that i could update my website let's say on trap17 from my localhost computer with a click
    of a mouse, without all of that ftp mambo-yumbo the thing is that i wanted an "UPDATE" button on my
    site which woud connect to my localhost and update all the things needed. let's say i added few
    profiles localy, and i want to update them on site.. how could it be done. if i was crude in
    explanation please write what info u still need and i'll post it back.......
  12. Display MySQL results in a Table
    question (8)
    hi all i know php and my sql i want to know how can show mysql result in this tabel for example :
    CODE <table cellpadding="0" cellspacing="0" width="200"
    height="151">     <!-- MSTableType="layout" -->     <tr>
            <td height="21" width="100" valign="top">1</td>
            <td height="21" width="100" valign="top">8</td>
        </tr>     <tr>         <td height="21" width="100" valign=&....
  13. Question: Securing A Website For Beginners
    (1)
    I don't really understand 'bout it. What kind of security we have to make to hold our web
    secure. Only log in features? how bout 'deface' method? how does it work? thx in advance
    Please use detailed topic title. ....
  14. How I Can Display Forum Topic On Main Website ?
    (4)
    Suppose i have a website.. domain.com , and have phpbb forums on domain.com/forums.. And i want to
    display the new topics written in the forum on the main page of website...how i can do that.. ? for
    example ,I want to display this topic `? "domain.com/forums/viewtopic.php?t=16" how can i do
    that ?....
  15. Sending Messeges Over A Website.
    (3)
    i want to learn how members of a website can send messeges to each other using php since im learning
    it. okay i can write in more detail..that for example if users can register on a website , suppose
    there are some users on the website , and now i want to learn how they can send messeges to each
    other.suppose each user has a unique ID ... and for example if some one has send the messege to
    other member of website , then he can know that he has recieved a new messege..something like inbox
    on the website where all of his messeges can be stored...lets say same way like on t....
  16. Requesting Auto Generating Id Tag In Php Code
    Php Coding (2)
    Hello...I'm designing a website in PHP where ppl can submit their links for "cool sites".
    Anyway, when somebody submit's a link to a website for example "http://www.google.com" it
    creates an id such as "index.php?id=1134411593". I dont want the links to be converted into
    id's. I want it to remain as "http://www.google.com". I have the following coding on
    ( echo " ). I'm a novice. Please Help!!!!
    Thanks... Plus I also want to add the date on when the link was submitted. Please follow our foru....
  17. Adding Users To Databases Using Phpmyadmin
    (2)
    I am running my own apache server with PHP and MySQL, with phpMyAdmin on my own computer, to test
    things locally. I know how to create databases and how to create users, but how can I add a user to
    a database?....
  18. Can My Forum And Website Use The Same Profiles?
    (3)
    I've been programming a 'rate-em' site from scratch. You know like Hot Or Not. YEs,..
    yet another rate-em website. Anyway, i'ts done and before I launch it I need to add a forum as
    the finishing touch, but all the forum softeware out there seems so hard to integrate. I'm
    trying to make it so that when a user logs into my rate-em website they are also logged into 'my
    forum'. i.e. i want my forum and web site to use the same profile data. If anyone knows of a
    forum program made for this objective please let me know. I'm in over my head, a....
  19. Music Website
    (3)
    http://www.metalmania.net I'm pretty much a novice when it comes to php/mysql and I have been
    trying to figure out how to build something similar to the way the site above works. Do any of you
    know of a tutorial or script or something that would show me how to accomplish something very
    similar to that? I have also been exploring phpnuke platinum with the TopMusic mod, but it just
    doesnt want to do what I want it to do. Sure it has a lot of features already done for me, but the
    architecture and navigation is very poor in my opinion, not nearly as efficent as the n....
  20. Html Within Php Coding
    Is there a way to read HTML Code? (11)
    Is there a way to have PHP read a text file, which contains HTML Code, not text to display. This
    way i have a simple code in every page, linking to this text file, and then if i'm wanting to
    change the code, i only need to change the code in the text file. If that all makes sense?
    /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> I get the feeling it
    can be done, but the only code i have seen is one that displays the contents of the text files.....
  21. Php/mysql Search Engine Help
    Having issues displaying results (1)
    I've been using a tutorial
    (http://www.devarticles.com/c/a/MySQL/Developing-A-Site-Search-Engine-With-PHP-And-MySQL/) at this
    address to help me get started on building my own search engine. I've completed the tutorial but
    when I run the search, I get no results on the results page. I'm wondering if anyone will take a
    look at this script and see if they can figure out why my I'm not getting any results displayed.
    I'm using phpMyAdmin to build the database and simple notepad to build the PHP script. CODE
    <?php $submit = $_POST[&....
  22. Free Website Portal
    (2)
    hey everyone, have you ever used PHP??? well if you have you know how cool it is and nice to work
    with and it has nice mods and stuff for it.... well i got the ultimate php its called
    PHP-Platinum very very very nice Portal and Engine Coding, slick sleek and smooth are 3 words for
    this portal... if you want to see it in action and see features of it or even download it and check
    it out for yourself visit this site PHP-Nuke Platinum Features & Downloads its a very nice
    thing to use so go check it out, i love it cause its got nice protection so your site stays s....
  23. Website Help
    Need php programmers to help me. (10)
    I need some php programmers help. I am working on a website. I have asked for some code in another
    topic and would now like help. These will possibly be sold. And if they do I am willing to pay the
    people who help me out a lot some of it. Dun start asking to help and like help a tiny bit and
    expect to get something big out of it. I am only paying to people who help a lot and once they are
    sent out. You must also be good with making clan websites. These will be for clans. If you bother me
    about getting money than no pay. More info on aim. My aim is generalds2001....
  24. Php Website Assistance?
    Help Me (1)
    Hello, i have just set up a website, and want to protect the site using login and password
    protection. Can anyone give me some PHP scripts which will keep a track of usernames and passwords,
    and add them to the access rights list. is this possible? If so, i would be much obliged if you
    would do so. Thank you. P.S If anyone needs assistance with HTML, that is my speciality, so send
    me a message. Always happy to help....
  25. Coding Your Sites ?
    Coding your sites (20)
    What kind of coding do you use on your sites? I have so far learnt using a little tables and
    div/css. /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> ....
  26. Help Importing Mysql Database Results
    Need help formatting link (3)
    I am having trouble formatting my table to display the results of a mySQL query the way I want.
    Here is the part of my code: CODE $result = mysql_query("SELECT * FROM uploads
    WHERE Category='Drama'") or die(mysql_error()); ?> <table
    cellspacing="2" cellpadding="2"> <tr> <th>Title</th>
    <th>Author</th> <th>File</th></tr> <?php // keeps
    getting the next row until there are no more to get while($row = mysql_fetch_array....
  27. Need Help With My Website
    (4)
    Hello, i have Invision Power Board v3, my website is http://www.generatione.trap17.com/forums] , I
    am doing this website for this organization. Anyhow, i still dont have a home page, but i have the
    forum part set up. And that is what i need some help on. and i had a couple of questions in which i
    was wondering if you guys new how to change these settings. How can i change the title of my
    website? The current one is New Directions - Forum (Powered by Invision Power Board). How can i
    put more links in for example in trap17 there are , i was wondering how could i ....
  28. Different Styles Of Mysql Coding.
    (2)
    I look around the place, and at my own MYSQl scripts, and most look the same except with a few
    differing factors. Now Im relativly new to MYSQL, and not so new to PHP. The problem is though, I
    havent been able to test my scripts/site out so Im not sure if my scripts are right. For example,
    heres a script to create my user table. CODE <?php $DBhost = "localhost";
    $DBuser = "********"; $DBpass = "*********";   $DBName =
    "*********"; $connection = @mysql_connect($DBhost,$DBuser,$DBp....
  29. Saving As .php
    Ehrm i'm a little newbie heh (15)
    I'm currently reading all tutorials on php... Trying to know SOMETHING about it. But i'm
    using FP to make my sites... That's because I got it for free. Anyway, how can I save the files
    as *.php? If I can't do it in FP, how can I do it? Dreamweaver?....
  30. Links To Lots Of Usefull Website
    I AM NOT SPAMING THIS TOOK ME 15 MINUTES (1)
    HELLO HERES A LIST OF LOTS OF USEFULL SITES I FOUND: || Codecs || http://www.free-codecs.com
    http://www.codecsdownload.com http://www.freecodecs.net http://www.click-now.net
    http://www.click-now.org || Search Engines || www.google.com www.search.com www.altalavista.com
    www.AllSearchEngines.com www.mamma.com || Programming Help Sites || www.patorjk.com
    www.planet-source-code.com www.freevbcode.com www.codearchive.com www.vbaccelerator.com
    www.vbcode.com www.abstractvb.com www.developerfusion.com www.codeproject.com www.extreme-vb.net ||
    Free Online Game Play || ....

    1. Looking for website, coding, databases, saving, form, results

Searching Video's for website, coding, databases, saving, form, results
Similar
Coding
Help! -
Need
Tutorial?
3;
What Coding
Languages
Are
Required?
Creating A
Login Box
That Links
To My Phpbb
Forum - Have
my phpBB
Forum
Intergrated
with my
Website
Help With
Coding!
- please
anybody help
me!
To Search
Within
Search
Results - To
search
within
search
results
New Found
Php Coding
Errors - I
always
thought
these
worked, but
suddenly
they no
longer
do?!
<?php
?> Get
Search
Results To
Your
Localhost -
Simple way
to get 100
results
without
allowing
cookies
Php
Frameworks -
Leaner, More
Efficient
Coding. - A
quick
overview of
what they
are and
where you
can find
some.
Help With
Moving Html
Form Results
To Shopping
Cart?
How To Group
Mysql
Results In A
List
Updating
Website From
Another --
Website - Is
it possible,
and how?
Display
MySQL
results in a
Table -
question
Question:
Securing A
Website For
Beginners
How I Can
Display
Forum Topic
On Main
Website ?
Sending
Messeges
Over A
Website.
Requesting
Auto
Generating
Id Tag In
Php Code -
Php Coding
Adding Users
To Databases
Using
Phpmyadmin
Can My Forum
And Website
Use The Same
Profiles?
Music
Website
Html Within
Php Coding -
Is there a
way to read
HTML Code?
Php/mysql
Search
Engine Help
- Having
issues
displaying
results
Free Website
Portal
Website Help
- Need php
programmers
to help me.
Php Website
Assistance?
- Help Me
Coding Your
Sites ? -
Coding your
sites
Help
Importing
Mysql
Database
Results -
Need help
formatting
link
Need Help
With My
Website
Different
Styles Of
Mysql
Coding.
Saving As
.php - Ehrm
i'm a
little
newbie heh
Links To
Lots Of
Usefull
Website - I
AM NOT
SPAMING THIS
TOOK ME 15
MINUTES
advertisement



Help With Some Website Coding - Databases and saving form results



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE