简体   繁体   English

重定向index.html中的链接

[英]Redirect link in index.html

Not sure where i am going wrong here... 不知道我在哪里错了...

I have a form that has a php file that is actioned when submit is pressed. 我有一个表单,该表单具有一个php文件,当按下submit时,该文件就会起作用。 Basically there are two fields, one is the url and the other the file name that the php file will create. 基本上有两个字段,一个是url,另一个是php文件将创建的文件名。

I need to amend a html file, with the url several times a week, but would also like to create new file for backup. 我需要每周修改几次html文件,但还要创建新文件进行备份。

I have the following two files.. 我有以下两个文件。

    <form action="action_page.php">
    YT Link:<br>
    <input type="text" name="ytlink" value="www.google.com">
    <br>
    File Name:<br>
    <input type="text" name="FName" value="test">
    <br><br>
    <input type="submit" value="Submit">
    </form>

and the php file.. 和PHP文件..

    <?php
    $myfile = fopen("$FName", "w");
    $txt = "text update here\n";
    fwrite($myfile, $txt);
    fclose($myfile);
    ?>

But when i run the form it does nothing.. any help would be much appreciated. 但是,当我运行表单时,它什么也没做。.任何帮助将不胜感激。 As you can see i am very new to php. 如您所见,我对php非常陌生。

Thanks in advance. 提前致谢。

you forgot to take the value in post 你忘了带走价值

<?php
$Fname= $_POST['Fname']; //add this line
$myfile = fopen("$FName", "w");
$txt = "text update here\n";
fwrite($myfile, $txt);
fclose($myfile);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM