Jump to content

Why Clicking SUBMIT Button Echoes I Did not Click It ?


2020

Recommended Posts

Folks,

 

Look at this weird thing.

I load the page and get echoed as expected: Did Not REQUEST_METHOD!

Then, I click the SUBMIT button and to my astonishment I get echoed: Did Not POST->Submit!

Got 2 buttons. Same result whenever clicking any.

Why is that ?

Check it out:

	<?php
//include('error_reporting.php');
ini_set('error_reporting',E_ALL);//Same as: error_reporting(E_ALL);
ini_set('display_errors','1');
ini_set('display_startup_errors','1');
?>
	<form name = "submit" method = "POST" action="">
<label for="domain">Domain:</label>
<input type="text" name="domain" id="domain" placeholder="Input Domain">
<br>
<label for="domain_email">Domain Email:</label>
<input type="email" name="domain_email" id="domain_email" placeholder="Input Domain Email">
<br>
<label for="url">Url:</label>
<input type="url" name="url" id="url" placeholder="Input Url">
<br>
<label for="link_anchor_text">Link Anchor Text:</label>
<input type="text" name="link_anchor_text" id="link_anchor_text" placeholder="Input Link Anchor Text">
<br>
<textarea rows="10" cols="20">Page Description</textarea>
<br>
<label for="keywords">Keywords:</label>
<input type="text" name="keywords" id="keywords" placeholder="Input Keywords related to Page">
<br>
<input type="checkbox" name="alert_visitor_type" id="alert_visitor_type" value="Give Alert: Visitor Type">
</label for="alert_visitor_type">Give Alert: Visitor Type</lablel>
<input type="checkbox" name="alert_visitor_potential" id="alert_visitor_potential" value="Give Alert: Potential Visitor">
</label for="alert_visitor_potential">Give Alert: Potential Visitor</lablel>
<br>
<input type="radio" name="tos_agree" id="tos_agree_yes" value="yes">
<label for="tos_agree_yes">Yes:</label>
<input type="radio" name="tos_agree" id="tos_agree_no" value="no">
<label for="tos_agree_no">No:</label>
<br>
<label for="tos_agreement">Agree to TOS or not ?</label>
<select name="tos_agreement" id="tos_agreement">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br>
<button type="submit" value="submit">Submit</button><br>
<button type="submit">Submit</button>
<br>
<input type="reset">
<br>
</form>
	<?php
	if($_SERVER['REQUEST_METHOD'] === 'POST')
{
    if(isset($_POST['submit']))
    {
        mysqli_report(MYSQLI_REPORT_ALL|MYSQLI_REPORT_STRICT);
        mysqli_connect("localhost","root","","test");
        $conn->set_charset("utf8mb4");
        
        $query = "INSERT into links (domain,domain_email,url,link_anchor_text,page_description,keywords,alert_visitor_type,alert_visitor_potential) VALUES (?,?,?,?,?,?,?,?)";
	        $stmt = mysqli_stmt_init($conn);
	        if(mysqli_stmt_prepare($stmt,$query))
        {
            mysqli_stmt_bind_param($stmt,'ssssssss',$_POST['domain'],$_POST['domain_email'],$_POST['url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keywords'],$_POST['alert_visitor_type'],$_POST['alert_visitor_potential']);
            if(mysqli_stmt_execute($stmt) === FALSE)
            {
                die("Error\" . mysqli_stmt_error()");
            }
            
            mysqli_stmt_close($stmt);
            mysqli_close($conn);
        }
        else
        {
            die("Did not INSERT!");
        }
    }
    else
    {
        die("Did Not POST->Submit!");
    }
}
else
{
    die("Did Not REQUEST_METHOD!");
}
	?>
	

Link to comment
Share on other sites

40 minutes ago, 2020 said:

if(isset($_POST['submit']))

You don't have any input fields named 'submit', so $_POST['submit'] won't exist.

Note: <form> tags are not inputs, giving them a name doesn't make them submit something.

 

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.