Jump to content

Recommended Posts

Hello

I have made a user registration page. I have question(s).

 

Is my workflow mentioned below true and working?

I have made an HTML+CSS (in php format) page and then have left the action attribute of registration form empty.

Then I have made a .php for processing the registration. I have made a conditional, that if(isset($_POST['submit'])) is true then INSERT INTO database and if false then include("htmlPage.php')

 

 

But my problem is that When I click on submit button nothing happens and the pages moves toward topmost as if the submit button is attached to an anchor point.

Edited by mostafatalebi
Link to comment
https://forums.phpfreaks.com/topic/272425-user-authentication-and-registration/
Share on other sites

If you leave it empty you post to yourself (the same page). So it's pretty much just refreshing the page because you don't have it set up to deal with the form data. If you press F5, you should get a warning that you're going to resend data if you'd like some proof of it posting.

I HAVE FOUND THE PROBLEM. THANKS

 

different from what I have already said:

the erro is about mysqli prepared statement syntax

this my form processor:

 

<?php

 

$input['firstname'] = "";

$sql = new mysqli("localhost", "root", "", "sample");

mysqli_report(MYSQLI_REPORT_ALL);

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

{

$input['firstname'] = htmlentities($_POST['firstname'], ENT_QUOTES);

if($stmt = $sql->prepare('INSERT INTO sampleData (firstname, last) VALUES (?,?))'))

{

$stmt->bind_param("ss", $input['firstname'],$input['firstname']);

$stmt->execute();

echo "Successfully Done.";

$stmt->close();

}

else

{

echo "failed";

}

}

 

 

?>

 

 

 

AND THIS IS MY HTML FORM

 

 

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Untitled Document</title>

</head>

<body>

<form action="inc/form_processor.php" method="post" >

<input type="text" name="firstname" />

<input type="submit" name="submit" value="Send" />

</form>

</body>

</html>

 

 

 

IT DOESN"T WORK. The problem is with my sql syntax

Edited by mostafatalebi
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.