2013-02-18 57 views
0

我有一個2文件PHP腳本,它允許用戶使用單個文本區域提交表單。該腳本創建一個新的PHP頁面並將用戶重定向到該頁面。我想向提交表單的用戶回覆文本,而不是其他人。你能幫助一個代碼示例嗎?向提交表單的用戶回覆文本

+7

是的,這是可能的。 – Shoe 2013-02-18 19:45:18

+2

他是對的,它是! – 2013-02-18 19:48:18

+0

你真的想要它創建一個全新的頁面嗎?或只是回聲無論用戶輸入什麼? – Nick 2013-02-18 19:50:44

回答

1

讓我知道如果這個心不是什麼youre尋找和虐待編輯相應:

HTML:

<input type = "text" name = "input"> 

PHP:

<?php 
//user input 
$userInput = $_POST['input']; 

//not sure how you are getting the email adress but however youre getting it it goes here 
$email = "[email protected]"; 

//create the filename 
$myFile = $userInput . ".php"; 

//create the file 
$fh= fopen($myFile, 'w'); 

//write to the file 
fwrite($fh, $email); 

//redirect to the new file 
header("location:". $userInput .".php"); 
?> 

基本上它會創建一個新的頁面基於關閉無論你的用戶輸入什麼,並顯示一個電子郵件地址給他們。我想這種方式只允許用戶看到它,因爲它基於他們輸入的內容。其他明智的做法最好的辦法是在用戶系統上存儲一個cookie(儘可能安全)