Jump to content

Recommended Posts

<?php

// create_user.php

      $username = $_POST['username'];
        $password = $_POST['user_pass'];

        $ss_name = $_POST['ss_name'];
        echo "ss_name: ". $ss_name. "<br/>";


?>
<!-- registration_page.php -->

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

<datalist id = "oecs_systems">
   
<?php

		include_once 'db_connect.php'; /*establish databse connection and create mysql object called msql2 */

	
		if ($stmt = $mysqli_obj2->prepare("SELECT ss_name FROM ss_systems ORDER BY ss_name")){
        
            $stmt->execute();   // Execute the prepared query.
            $stmt->store_result();
 
            
                $stmt->bind_result($ss_name);
                while($stmt->fetch()){
                   	echo "<option value=\" $ss_name\">";
                }
			
        }
        else{
			echo "Error in preparing database statement to display Social Security Systems <br/>";
        }        
			


?>
</datalist>

        <label for = "ss_name"> Social Security Organization:</label>
        <input  id = "ss_name" list = "oecs_systems"/> <br>        
	
		<input name="Button" type="submit" value="Create user account" />
	</form>

?>

I create a data list in my source file registration_page.php. However when this page then invokes "create_user.php", the "ss_name" id used for the data list echoes nothing to the screen as if nothing was selected.

 

Why can't I read the datalist selection?

 

I have added the code s well

 

 

Link to comment
https://forums.phpfreaks.com/topic/289922-reading-datalist-selection-in-php/
Share on other sites

Thank you so much. It worked by adding the "name" attribute. For some reason, I thought I read somewhere that the "id" attribute was the replacing the use of the "name" attribute so both are note needed, but in this case it really works!. Thanks so much.

 

Telly

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.