DEV Community

Festus Francis
Festus Francis

Posted on

VsCode Snippet Duplicates Variables

Hi, here is my login code snippet on VsCode. The snippet works as it should, but the problem is when I change the $$Email variable to username and I hit Tab key, the $Email variable $$_POST['$Email'] gets duplicated to $_POST['username$username']. The same also goes for Pword. How do I remedy this, please?

"Login": {
"prefix": "Login",
"body": [
"include '$connectdb.php';",
"$$Email = $$_POST['$Email'];",
"$$Pword = $$_POST['$Pword'];",
"$$sql = \"SELECT * FROM $staff WHERE Email = '$$Email' AND Pword = '$$Pword'\";",
"$$result = $$conn->query($$sql);",
"if (mysqli_num_rows($$result) == 1) {",
" $$row = mysqli_fetch_assoc($$result);",
" if ($$row['Email'] == $$Email && $$row['Pword'] == $$Pword && $$row['Role'] == '$Student') {",
" header('Location:$profile.php?id='.$$row['id']);",
" } elseif ($$row['Email'] == $$Email && $$row['Pword'] == $$Pword && $$row['Role'] == '$Admin') {",
" header('Location:$Admin.php?id='.$$row['id']);",
" }",
"} else {",
" header('Location:$index.html');",
"}"
],
"description": "Login to db"
}

Top comments (0)