php - dropdown option select in register form -


I am creating a register form with a dropdown selection option:

Name: Email: Password: School: (dropdown option list) I have set up two tables, which are called "users", others are "schools". In my "Users" table, the columns are "id" (int (11)) , "email" (varchar (255) , "name" (my In the "School" table, the column "id" (int (11)), "user_id" (int (11)), varna (64) , and "school" (kirtava (64) and "school_id" Int (11)) "I'm not sure if the setup of this table is correct, please let me know if there is a better way to set it up. I made" school_id "as I have a search system later on where the user In specific schools

So far my farm form of register.html:

  form action = "register e-mail: & lt ; / Label & gt; & lt; php "method =" post "& gt; div class =" field "& gt; & lt; label =" email "for input type =" email "id =" email " = "" Autocomplete = "on" action = "">  gt; 
label = "password" & gt; password: & lt ; / Labels & gt; & lt; br / & gt; Input type = "password" id = "password" auto-integer = "off" /> gt; & Lt; / Div & gt; & Lt; Div class = "area" & gt; & Lt; Label = "name" & gt; Name: & lt; / Label & gt; & Lt; Br / & gt; & Lt; Input type = "text" id = "name" action = "" /> & Lt; / Div & gt; & Lt; Div class = "field" & gt; & Lt; Label = "school"> School: & lt; / Label & gt; & Lt; Select ID = "school" size = "1" & gt; & Lt; Option value = "A" & gt; Apple school & lt; / Option & gt; & Lt; Option value = "b" & gt; Banana school & lt; / Options & gt; & Lt; Option value = "c" & gt; Carrot School & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; Input name = "register" type = "submit" id = "register" value = "" /> & Lt; / Form & gt;

and my register.php:

  & lt; Php require_once 'core / init.php'; If (Input :: exists) (if (token :: check (input :: find ('token')) {$ valid = new valid (); $ Validation = $ validate- & gt; check ($ _ POST, array ('email' = & gt; array ('required' = & gt; true, 'min' => 2, 'max' => 255, 'unique' = & gt; user '', 'Password' = & gt; array ('required' => true, 'min' => 6), 'name' => array ('required' = & gt; true, minute '= & Gt; 2,' max '=> 50), // I do not know how to leave the school here))); If ($ validation-> passed ()) {$ user = new user (); $ Salt = hash :: salt (32); {$ User- & gt; Make (arrow ('e-mail' = & gt; input: get ('email'), 'password' = & gt; hash :: create (input :: get ('password'), $ salt ), 'Salt' = & gt; $ salt, 'name' = & gt; Input :: find ('name'), 'school' = & gt; input :: mill ('school'), 'connected '= & Gt; (' YMD HH: I: S '),)); Session :: Flash ('Home', 'You are registered and can now log in!'); Redirected to: ('index.php'); } Hold (exception $ e) {dead ($ e-> getMessage ()); }} Else {foreach ($ validation-> errors) as $ error) {echo $ error, '& lt; Br> & # 39; & # 39; }}}}? & Gt;  

If there are other ways to do this, please help me. I found OP login / tutorial through phpacademy in this way.

I think you should change your table in this format

User table

"id" (int (11)) , "email" (Varchar (255) , "Name" (varchar (64) , and "school_id" (int (11))

school tables

"id" (int (11)) , "school_id" (int (11)) ", and " school_name "(varchar (255) )

Now you can access the school table to keep the drop down in your code.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -