2012-06-14 2 views
-1

다른 페이지의 양식에서 수집 된 데이터를 사용하여 HTML 페이지를 생성하려고합니다.PHP 함수로 생성 된 페이지 찾기

<html> 
<body> 

<meta http-equiv="cache-control" content="private" > 
<link rel="stylesheet" type="type/css" href="vytran_css.css" /> 


<head> New Product Introduction </head> 

<p> In order to begin the process of introducing a new product, please complete 
the following form. Once you are satisfied with your responses to the various 
prompts, please click on the submit button at the bottom of the page. If you 
would like to start over, click the Reset button. If you have any questions, 
Please follow the link that says "Help". 


<form action="html_data.php" id=from1 method="post"> 
Product Name: 
<input name="Name" size="20" type="text"> 
<br><br> 

Project Lead Name: 
<input name="PLname" size="20" type="text"> <br><br> 

Team-members: <br> 
<textarea name="Team-members" rows=10 cols=40 type="text"> </textarea> <br><br> 

Product Type: <br> 
<input name="Product Type" size="20" type="text"> <br><br> 

Description: <br> 
<textarea name="Description" rows=10 cols=40 type="text"> </textarea> 
<br> 

<br> <br> 



<input value="Submit" type="submit" name="formSubmit"> 
<input value="Reset" type="reset"> 
<input value="Help" type="button" onclick="window.location.href='problems.html'"> 
</form> 
</p> 

</body> 
</html> 

을하고 html_data.php 페이지에서 I는 다음과 같습니다 : 나는 양식을 사용하여 HTML 페이지에이 태그가이 내가 그것을 할 것을 요청하고 어떻게해야

<?php 
    ob_start(); // start trapping output 
    $name = @$_POST['Name']; 
?> 
<html> 
<body> 
<p> 
Product Name: <?php echo $Name; ?><br> 
Project Lead: <?php echo $PLname; ?><br> 
Team Members: <?php echo $Team-members; ?><br> 
Description: <?php echo $Description; ?> 
</p> 
</body> 
</html> 
<?php 
    $output = ob_get_contents(); 
    $newfile="output.txt"; 
    $file = fopen ($newfile, "w"); 
    fwrite($file, $output); 
    fclose ($file); 
    ob_end_clean(); 
?> 

. 양식은 문제없이 제출되지만 일단 제출하면 해당 페이지를 찾을 수 없습니다. 내가 바꿀 필요가있는 어떤 아이디어? 양식에서

+3

페이지를 찾을 수 없다는 것은 무엇을 의미합니까? 브라우저에 나타나지 않습니까? 어떤 웹 서버를 사용하고 있습니까? – Sgoettschkes

+3

"제출 한 페이지를 찾을 수 없다"는 것은 무엇을 의미합니까? 양식에 문제가 없다고 말하면됩니다. 당신이 쓰고있는 파일 말이에요? 너는 그것의 이름을 모른다? 그것은'output.txt'입니다. –

+0

hmm $ name 및 'Name', 중첩 된 2 개의 양식이 코드입니까? –

답변

2

변경에서

<textarea name="Team-members" rows=10 cols=40 type="text">

당신의 html_data.php에서

<textarea name="Team_members" rows=10 cols=40 type="text">

<?php echo $Team_members; ?>

<?php echo $Team-members; ?> 에서 6,

변화는 분명히 팀과 구성원 사이의 대시에 문제 있습니다.

  • PHP는 하이픈을 마이너스로 취급합니다.

  • 즉 : 당신이 제출 후 화면 echo에 데이터를 원하는 경우 팀 마이너스 회원 그리고

,이 일

echo $output; 

ob_end_clean(); 아래에 추가 나를 위해.

+1

그 수치. 유효한 변수 이름은 문자 또는 밑줄 뒤에 숫자, 문자 또는 밑줄이옵니다. " 변수 이름에는 하이픈을 사용할 수 없습니다. – lotsoffreetime

+0

기꺼이 도와 드리겠습니다. 건배 ~ –

+0

스타일 : 파일에'추가 '를하려면'a +'지시어를 사용하십시오. 게다가 어떤 스타일을 추가하고 싶다면'.shtml'이나'.php' 확장자로 파일의 이름을 정하고'include!'파일을 맨 위의 박쥐 (예 :''또는'PHP'와 동등하며 그 안에는 표시 할 스타일 지정 내용이나 추가 헤더를 넣으십시오. –

관련 문제