CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2182|Reply: 3

PHP form

[Copy link]
Post time 15-12-2007 10:24 PM | Show all posts |Read mode
Saya mempunyai 2 form dalam 2 php file yang berbeza. User dikehendaki mengisi kedua-dua form tetapi value yang dimasukkan user dalam form 1 (file1.php) perlu retrieve selepas form2 diisi dan submit. Saya telah pass ke variables tersebut ke file2.php dan guna $_GET untuk retrieve. Tapi selepas submit form2, value tersebut 'hilang'. Macam mana saya nak retrieve dan simpan dalam variable yang tak akan hilang selepas submit? Saya perlu values dari kedua-dua form untuk insert ke dalam database. Terima kasih.
Reply

Use magic Report


ADVERTISEMENT


Post time 15-12-2007 10:56 PM | Show all posts
guna $_REQUEST senang

kat file2.php

try gini

$nilai =  $_REQUEST;

$nama1 = $nilai['nama_textfield'];


echo $nama1;
Reply

Use magic Report

Post time 16-12-2007 12:17 AM | Show all posts
(1) guna hidden fields to bring values in file1.php and file2.php

atau

(2) guna session variables ( $_SESSION )
Reply

Use magic Report

 Author| Post time 16-12-2007 01:56 AM | Show all posts
Kalau cara saya guna $_SESSION betul tak? Code ni dlm file yang kedua ..

session_start();
$test=$_GET['do'];

$_SESSION['testing']=$test;

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
session_start();       
$test=$_SESSION['testing'];
...

$sql=mysql_query("INSERT INTO Test (test)
                             VALUES ('$test')");

................
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

5-1-2025 09:42 AM GMT+8 , Processed in 0.071004 second(s), 17 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list