<html>


<head>

<title>Applicant Login Page </title>

</head>

<center>
<body bgcolor = "#000000" text = "#70db93">
<h1> Passport System <hr> </h1>
</center>

<form>
<p> Fill in the form below.
</p>

Title <input type = "radio" name = "response" value = "Mr" checked = "checked"> Mr
      <input type = "radio" name = "response" value = "Mrs"> Mrs
      <input type = "radio" name = "response" value = "Ms"> Ms
      <input type = "radio" name = "response" value = "Dr"> Dr
      <input type = "radio" name = "response" value = "Sir"> Sir
<br>
</p>
<p>
First Name <input type = "text" name = "First Name" size = "30" maxlength = "30"> <br>
Last Name <input type = "text" name = "Last Name" size = "30" maxlength = "30"> <br>
Username <input type = "text" name = "Username" size = "30" maxlength = "30"> <br>
Password <input type = "password" name = "Password" size = "30" maxlength = "30"> <br>
Retype Password <input type = "password" name = "Retype Password" size = "30" maxlength = "30"> <br>
Fathers Name <input type = "text" name = "Fathers Name" size = "30" maxlength = "30"> <br>
Mothers Name <input type = "text" name = "Mothers Name" size = "30" maxlength = "30"> <br>
Place of Birth <input type = "text" name = "Place Of Birth" size = "30" maxlength = "30"> <br>
Address <input type = "text" name = "Address" size = "50" maxlength = "50"> <br>
Nationality <input type = "text" name = "Nationality" size = "20" maxlength = "20"> <br>
Gender? <input type = "radio" name = "response" value = "female" checked = "checked"> female
        <input type = "radio" name = "response" value = "male"> male <br>

<input type = "submit" name = "register" value = "Register">

</p>
</form>
</body>
</html>

Once a person has filled in the forms, i want the data to be stored in a database...i'm not exactly sure how to connect to a databse in either mysql or access..please help. only started doing html yesterday been at it for the past 10hours

One more thing, i have two radio button options..the first being one has to choose his/her title i.e Mrs,Mr or whtever and the other he/she has to choose his/her gender buh on this i can't manage to make each work. when the title is chosen the gender becomes blank..and vice versa

Dani AI

Generated

Brief recap and clear next steps based on the thread: built a static HTML form and wants to save submissions to a database; was correct that a server-side script is needed; already pinpointed the radio problem (both groups use the same name). The checklist below fixes the form behavior, shows a safe schema, and gives a minimal, secure PHP workflow to insert data.

Fix the form controls (no spaces in name, distinct names for each radio group). Example HTML fragment showing naming convention and grouping:

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

  <label><input type="radio" name="title" value="Mr" checked> Mr</label>
  <label><input type="radio" name="title" value="Mrs"> Mrs</label>

  <label><input type="radio" name="gender" value="female" checked> female</label>
  <label><input type="radio" name="gender" value="male"> male</label>

  <input type="text" name="first_name">
  <input type="text" name="last_name">
  <input type="password" name="password">
  <input type="submit" value="Register">
</form>

Radio buttons are grouped by the name attribute; giving title and gender different names prevents one group from clearing the other. See MDN for radio-button grouping. (developer.mozilla.org) The <form> method/action attributes control how and where data is sent; use POST for inserts. (developer.mozilla.org)

Minimal database schema (MySQL example):

CREATE TABLE applicants (
  id INT AUTO_INCREMENT PRIMARY KEY,
  title VARCHAR(10),
  first_name VARCHAR(50),
  last_name VARCHAR(50),
  username VARCHAR(50) UNIQUE,
  password_hash VARCHAR(255),
  gender ENUM('male','female','other'),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Server-side: read $_POST values (they are indexed by form name), validate and sanitize, hash the password with password_hash(), and use PDO prepared statements to avoid SQL injection. Example PHP sketch:

<?php
if ($_SERVER['REQUEST_METHOD']==='POST') {
  $p = $_POST;
  $pw = password_hash($p['password'] ?? '', PASSWORD_DEFAULT);
  $pdo = new PDO('mysql:host=localhost;dbname=appdb;charset=utf8mb4','dbuser','dbpass',[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);
  $stmt = $pdo->prepare('INSERT INTO applicants (title, first_name, last_name, username, password_hash, gender) VALUES (:title,:first,:last,:user,:ph,:gender)');
  $stmt->execute([':title'=>$p['title'],':first'=>$p['first_name'],':last'=>$p['last_name'],':user'=>$p['username'],':ph'=>$pw,':gender'=>$p['gender']]);
}
?>

$_POST behavior and usage documented on php.net; use PDO prepared statements and password_hash() for safety. (php.net)

Troubleshooting/cautions: enable error reporting during development, var_dump($_POST) to inspect submissions, confirm the host supports PHP+MySQL (as asked), and remember AJAX (as suggested) still requires the same server-side processing.

Recommended Answers

All 4 Replies

Member Avatar for Member #920377

Hi eLu-sive,

Does the website already have an existing database set up for you to save your form results to, including all the database tables? If so, do you know your password to connect to the database? Do you definitely have MySQL or Access available on your hosting environment? What other information can you provide about your hosting environment, like does it have PHP or ASP enabled on it?

This could be done by passing your form into a php or any dynamic page which will store the data submitted into a database or csv or whatever.

Repeating Feemacbee's observations - where is the data supposed to go? The form needs both a method ('get' or 'post') and an action (the script that's going to double check and process it.) As in

<form method="post" action="../cgi-bin/monster.pl">

or

<form id="Form_Contact" action="contact.php" method="post">

And the reason your 'Mr/Mrs' section and gender are cancelling each other out - you're using the same name for both sets of elements, making them part of the same 'question'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.