Jump to content

information to a database


mandukar

Recommended Posts

hi i'm trying to make a web page where someone can fill in a form and the information can be then sent to a database.

 

can someone tell me how I can go about doing this?

heres the forum I wish to use

 

basiclly its

char name:

Char Gender:

background:

 

<form name="form1" method="post" action="">

  Character name:

  <label>

  <input name="Character name:" type="text" id="Character name:">

  </label>

  <p>Character Gender:

    <label>

    <input name="Character Gender:" type="text" id="Character Gender:">

    </label>

  </p>

  <p>Background information:

    <label>

    <textarea name="background information:" id="background information:"></textarea>

    </label>

  </p>

  <p>

    <label>

    <input type="submit" name="Submit" value="Submit">

    </label>

    <label>

    <input type="reset" name="Submit2" value="Reset">

    </label>

  </p>

</form>

 

thanks in advanced

 

Link to comment
https://forums.phpfreaks.com/topic/49474-information-to-a-database/
Share on other sites

I would recommend you to change your form name to words that doesn't include spaces, I will write a short example on it to let you see, hope you can understand from it.

 

<html>

<head>
</head>

<body>

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <input type="text" name="test" size="20"><input type="submit" value="Submit" name="submit">
</form>

</body>

</html>
<?php
if (isset($_POST['submit'])) { // (1)
echo $_POST['test']; //(2)
// scripts
}
?>

 

For the example I had use POST action.

(1) - This line is just to check whether the submit button had been pressed, take note of the submit button's name.

(2) - $_POST['test'] this is how you can get the value that submitted in form test, take note of the form's name.

 

As for the // scripts, you can continue from there yourself.

Take a look on this tutorial how to submit data into the database, http://www.php-mysql-tutorial.com/mysql-insert-php.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.