开发者

i need some help (registry system) - php+mysql

开发者 https://www.devze.com 2023-02-25 04:51 出处:网络
My problem is not with how to write the code, but in the database strategy and the best way to write to the database.

My problem is not with how to write the code, but in the database strategy and the best way to write to the database.

My HTML has 2 divs, and each div represents a section. In the first section, the user enters their name, email, and password. In the second section, the user enters their address, country, and job.

Is best to save the values to the database as each section is completed? Or is it better to submit all values from both sections at one time? I prefer to insert into the db each section independently.

Another question, it is best to have a unique table for all data where fields from both sections are saved in a single record, or should I create two separate tables? If I create two separate tables, how do I connect them? (ok...foreign key, but i don't have mu开发者_Python百科ch experience in DB)

Thanks


I would store each slides values into the $_SESSION var. When finished with registration, send the $_SESSION values to the DB.

somewhere on top of your scripts

session_start();

slide 1 When finished, do this:

$userinfo = array();
$userinfo['name'] = $name_from_formular;
$userinfo['mail'] = $mail_from_formular;
$_SESSION['userinfo'] = $userinfo;

slide 2

if(isset($_SESSION['userinfo'])) {

    $userinfo = $_SESSION['userinfo'];

}

$userinfo['country'] = $country_from_formular;
// ....
$_SESSION['userinfo'] = $userinfo;

submit data

(read from $_SESSION and send it to the DB)

0

精彩评论

暂无评论...
验证码 换一张
取 消