Home > other >  Parse error: syntax error, unexpected variable "$POST", expecting ")" in C:\xam
Parse error: syntax error, unexpected variable "$POST", expecting ")" in C:\xam

Time:02-10

I am working on a signup page in html:

<form id="myForm">
<div >
<p>Username:</p>
<div  id="incorrect-a"><font size="2.3584782562126348594">Username must be a minimum length of 7 characters</font></div>
<input placeholder="Username" id="inc-a"></input>
<p>Email:</p>
<div  ><font size="2.3584782562126348594">Invalid Email</font></div>
<input placeholder="Email" id="incb"></input>
<p>Password:</p>
<div ><font size="2.3584782562126348594">This password is not of good quality.</font></div>
<input placeholder="Password"></input>
<button  onclick="mfunction();" type="button"><span>Submit</span></button>
</div>
</form>
<script src="./signup.js" defer></script>
const form = document.getElementById("myForm");
form.addEventListener("submit",mfunction())

function mfunction(e){
    const a = document.getElementById("inc-a").value;
    const b = document.getElementById("incb").value;
    console.log(a);
    var at = a.length;
    if(at<=7){
        console.log(2);
        const inca = document.getElementById("incorrect-a");
        inca.classList.add("show");
        setTimeout(()=> inca.classList.remove("show"), 5000)
    }
    if (b.indexOf('@') > -1) {
    console.log('has @');
}
    else{
        console.log(3);
    }
    const request= new XMLHttpRequest;
    
    request.open("post", "signup.php")
    
    request.onload = function() {
        console.log(request.responseText)
    }
    request.send(new FormData(form));
}
<?php
var_dump(_$POST);
?>

I should save the data and then present it in the console but instead, I find this in my console: br /> Parse error: syntax error, unexpected variable "$POST", expecting ")" in C:\xampp\htdocs\social\signup.php on line 2
And google has been not helpful. Stack Overflow is my last hope: Please help!

CodePudding user response:

  •  Tags:  
  • Related