Question:

Making a from using dreamweaver, php and SQL

by  |  earlier

0 LIKES UnLike

Hi I am trying to make a form, so when one submit it, the information goes to sql database, and then I want to be able to access the data, for example show them in another page, or email them. I have allready found a code that dosen't need SQL and what it dose is that you can fill out the form, and then it email you information to me. but how can I submit the information to SQL and then access them.

Thanks

 Tags:

   Report

1 ANSWERS


  1. HTML form:

    <form action="phpform.php" method="post">

    <input type="text" name="content">

    </form>

    PHP form:

    <?php

    $content = stripslashes($_POST['content']);

    mail ('you@you.com', 'Form Contact', $content);

    //require_once($_SERVER['DOCUMENT_ROOT...



    $host="yourhost"; // Host name

    $username="yourusername"; // Mysql username

    $password="yourpword"; // Mysql password

    $db_name="databasename"; // Database name

    // Connect to server and select databse.

    mysql_connect("$host", "$username", "$password")or die("cannot connect");

    mysql_select_db("$db_name")or die("cannot select DB");

    CREATE TABLE content (

    id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,

    content VARCHAR NOT NULL,

    PRIMARY KEY (id)

    )

    INSERT INTO content (content) VALUES ('".addslashes($_POST['content'])."')

    That's all I can give you based on the information given. To learn PHP and MySQL, go to http://www.w3schools.com/

    Hope I helped! ;P

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.