Hi guys, can you please help me with this code. my form keeps on submitting even if the form is empty. Thanks in advance
<?php
if(isset($_POST["submit"])){
if(!empty($_POST['address'])){
echo "The form is empty";
return false;
}
}
?>
<script>
function validate(){
var Tsontso = document.forms["Otris"]["address"].value;
if(Tsontso == ""){
alert("Please fill in the form");
return false;
}
else{
var Tsontso = document.forms["Otris"]["address"].value == "add";
}
}
</script>
If you’re posting code, you need to precede it with a line containing only three backticks ``` and end it with a line contining only three backticks.
<html>
<head>
<?php
if(isset($_POST["submit"])){
if(!empty($_POST['address'])){
echo "The form is empty";
return false;
}
}
?>
<script>
function validate(){
var Tsontso = document.forms["Otris"]["address"].value;
if(Tsontso == ""){
alert("Please fill in the form");
return false;
}
}
</script>
</head>
<body>
<form name = "Otris" onsubmit = "validate()" action = "Tson.php" method = "post">
<input type = "text" name = "address">
<br/>
<input type = "submit" value = "Submit" name = "submit">
</body>
</html>
can you also help me display the on to the <form action = "Tson.php">
here is my code for trying to display the input: Hello<?php echo $_POST["address"]; ?>
As i said previously do you closing the form using
. Because as per your code your are not doing that. I also like to advice you that when you ask any particular person in that case you should mention the name of that person.