0

Hi webdevelopers,

I am trying to INSERT INTO a table, a RETRIEVED gender SELECT FROM another table, but it misses a piece of code, to function:

$page_title = 'Register';
include ('./header2.html'); 

// Connect to the database.
require_once ('./Script14.1_mysql_connect.php');
if (isset($_POST['submitted'])) {

if  (!empty($_POST['types']) && ($_POST['types_id']) > 1) {
$g = (int) $_POST['gender'];
} else {
$g = FALSE;
echo '<br ><font color="white" size="-1">Please choose your gender!</font>';
}
} 

if ($g) {
$query = "INSERT INTO ..... (gender) VALUES ('$g' )";
        if ($result = mysqli_query ($dbc, $query)) {//or trigg_error.....

?>
<!--right part start -->
					<div id="right">
						<h3 ><em>Become a member</em><br />
						Join now! </h3>
						<p class="text Estilo8"> Fields with asterisks are obligatory* !
						<br />Password: use only letters and numbers. It must be between 4 and 20 characters long.</p>
						<br />
												
						<form method="post" action="register1.php">
												
<p><font color="pink" > <label>Gender: *</label>
<select name="gender"> <option> Select One</option>
<?php 
$query = "SELECT gender FROM types ";
$result = mysqli_query ($dbc, $query);
while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) {
echo "<option value=\"{$row ['types_id']}\">{$row['gender']}</option>\n";
}
mysqli_close($dbc);

include ("./footer.html");

</select></p>   

?>

Does someone knows what is missing, please?

Many thanks!

Masks.be

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Masks.be
0

in this piece of code

$query = "SELECT types_id,gender FROM types ";
$result = mysqli_query ($dbc, $query);
while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) {
echo "<option value=\"{$row ['types_id']}\">{$row['gender']}</option>\n";

try to retrieve types_id in select query.

0

Hi replies,

It is difficult to see your name.

Thanks but it is not that, the code says

SELECT gender FROM types "

.

It seems it is missing a <form> around the $query; but there is already another <form> involving.

Masks.be

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.