0

I have a form that include input with name "link" and php with $_POST['link'] but when I try to run it it show me

Notice: Undefined index: link

I know I need isset and that thing, but that's not problem. Problem is if I insert a link on my page and click on button why it won't load it in addnewacc.php

Added var_dump($_POST); --> result: array(0) { } even though I insert link in my input

This is my html form code

<form class="platf" action="php/addnewacc.php">
<span>Insert facebook link:</span><br><br>
<input type="url" required autocomplete="off" name="link"  value="https://www.facebook.com/"/>
<button type="submit" class="submitlink">Add FB account</button>
</form>

This is addnewacc.php code

<?php
    session_start();
    $username = $_SESSION['username'];
    $link = $_POST['link'];
    echo $username." facebook link: ".$link;
?>

I expected that post will catch my "link" from form.

1 Answers1

0

You need to use the post method in your form. It will be similar to this:

<form action='post' class="platf" action="php/addnewacc.php">
ASSILI Taher
  • 1,210
  • 2
  • 9
  • 11