This question already has answers here:
How can I get useful error messages in PHP?
(41 answers)
Closed 2 years ago.
My html is not sending field data to php in same file until action and method attribute are placed.... kindly identify my error and guide me.....
<pre><code>
<?php
if(isset($_post['submit'])){
echo "Yes is is working";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>testing form</title>
</head>
<body>
<br><br><br><br>
<form action="test.php" method="post">
<input type="text" name="name" placeholder="Enter Name"><br>
<input type="text" name="location" placeholder="ENter location"><br>
<input type="submit" name="submit">
</form>
</body>
</html>
</pre></code>
Probably you could try by setting id instead of name.
Eg.
<form action="test.php" method="post">
<input type="text" id="name" placeholder="Enter Name"><br>
<input type="text" id="location" placeholder="ENter location"><br>
<input type="submit" id="submit">
</form>
Related
If I have two inputs like the following
<input type="text" name="id">
<input type="text" name="name">
Then it is possible to get values in array on backend like this
array("id"=>"name")
If it is possible then how it can be done?
Hope you are doing well and good.
Umm, I just got your query. You want to make id as a key and name as a value in array. So here, May be i found your solution.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<form method="post">
<input type="text" name="id[]">
<input type="text" name="name[]">
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$combineArr = array_combine($_POST['id'], $_POST['name']);
print_r($combineArr);
}
?>
From the above code you can get answer like below,
Array ( [id] => name )
You can send your post via POST method.
<form name="form" action="" method="post">
<input type="text" name="id">
<input type="text" name="name">
<input type="submit" name="submit_button"
value="Send"/>
</form>
After that :
<?php
$array = [$_POST['id'] => $_POST['name']];
This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 5 years ago.
I am trying to load my start page (php) on localhost with xampp. As long as I keep the file an html document (saved as start.html) it is showing up but as soon as I save it as a php file (in order to execute the $_SESSION['id'] it fails to load the file (basically an infinite loading process but no errors showing up. Here is my code. Any help is highly appreciated. Thanks
<?php
session_start();?>
<html>
<head>
<title>
I am a login project
</title>
<meta charset="utf-8">
<link rel="stylesheet" href='style.css' type="text/css">
</head>
<body>
<form method="post" action="login.php">
<input type="text" placeholder="uid" name="Username">
<input type="password" placeholder="Password" name="pwd">
<button type="submit" name="submit">LOGIN</button>
</form>
<br>
<?php
if(isset($_SESSION['id'])){
echo $_SESSION['id'];
}
?>
<form method="post" action="signup.php">
<input type="text" placeholder="first" name="first">
<input type="text" placeholder="last" name="last">
<input type="text" placeholder="uid" name="Username">
<input type="password" placeholder="Password" name="pwd">
<button type="submit" name="submit">SIGN_UP</button>
</form>
<br>
<form method="post" action="logout.php">
<button type="submit" name='logout'>LOGOUT</button>
</form>
</body>
</html>
session start should happen before any output. there is a space before your opening php tag
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
I have a question here. Somehow my created registration form doesn't appear on the website. When I am deleting all the include files, it shows, but with the files - it does not. Could someone help me to solve this problem? What I'm doing wrong?
Here is my register.php file:
<!DOCTYPE html>
<?php
include 'classes/connection.php';
include 'classes/register.php';
$connection = new Connection();
$users = new Users($connection);
$users->insertUserValues();
?>
<html>
<head>
<meta charset="UTF-8">
<title>
</title>
</head>
<body>
<div class="form">
<form method ="post" action="register.php">
Vardas:<br>
<input type="text" name="name" id="name" placeholder="Vardas" required>
<br>
Pavardė:<br>
<input type="text" name="surname" id="surname" placeholder="Pavardė" required>
<br>
Prisijungimo vardas:<br>
<input type="text" name="username" id="username" placeholder="Prisijungimo vardas" required>
<br>
Slaptažodis:<br>
<input type="password" name="password" id="password" placeholder="Slaptažodis" required>
<br>
Patvirtinti slaptažodį:<br>
<input type="password" name="confirm_password" id="confirm" placeholder="Slaptažodis" required>
<br>
El. pašto adresas: <br>
<input type="email" name="email" id="email" placeholder="El. pašto adresas" required>
<br><br>
<input type="submit" name="submit" id="submit" value="Registruotis">
</form>
</div>
</body>
The link I'm entering to the registration form is correct, I've also tried to go from index.php, but it's the same..
Without checking if $_POST['submit'] was set (or any other post var), you immediately call $users->insertUserValues();
What happens inside that? Can we see? I would suggest an if statement to check the form was posted before trying to process non-existent data.
This question already has answers here:
How do I make a PHP form that submits to self?
(6 answers)
Closed 6 years ago.
I am trying to submit a form by post method on itself. but every time the form submits and page is refreshed. it doesn't show values.
<?php echo $_POST['fname']; ?>
<form method="POST" action='#.php'>
<input type="text" name="fname" id="fname" />
<button id="check" name="check" type="submit">GO</button>
</form>
What's the point, i am missing?
Try this :
<?php echo $_POST['fname']; ?>
<form method="POST" action=""> <!-- not single quote -->
<input type="text" name="fname" id="fname" />
<input type="submit" name="value" >
</form>
Try this...
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "<pre>";
print_r($_POST);
}
?>
<form name="test" action="" method="post"><input type="text" name="firstName" /><input type="submit" name="Submit" /></form>
I would recommend to write more cleaner way. like this:
<?php
if(isset($_POST['fname']) && !empty($_POST['fname']) ){
echo $_POST['fname'];
}
?>
<form method="POST" action=""> <!-- not single quote -->
<input type="text" name="fname" id="fname" />
<input type="submit" name="value" >
</form>
I'm writing a little website for myself and I'm having trouble with what seems like a simple line of code:
form action="send.php" method="post"
Furthermore, even a simple line like form action="http://www.google.com"> isn't working. Here is my code:
<html>
<head>
<title>
AnonMail!
</title>
</head>
<body style="font-family:'Tahoma';>
<form action="send.php" method="post">
<label for="from">From: </label><input type="text" name="from" id="from"></input></br>
<label for="to">To: </label><input type="text" name="to" id="to"></input></br>
<label for="subj">Subject: </label><input type="text" name="subj" id="subj"></input></br>
<textarea rows=10 cols=100 name="message"></textarea></br>
<input type="submit" value="Send"/>
</form>
</body>
</html>
The error starts with your body tag.
You have not closed your double quotes in the style tag of your body.
Just close it properly and then run it.
I think that is only the problem.
Here's a form that should work:
<html>
<body>
<form action="contact.php" method="post">
<p><b>Your Name:</b> <input type="text" name="yourname" /><br />
<b>Subject:</b> <input type="text" name="subject" /><br />
<b>E-mail:</b> <input type="text" name="email" /><br />
Website: <input type="text" name="website"></p>
<p><input type="submit" value="Send it!"></p>
</form>
</body>
</html>
If you're still having troubles: http://myphpform.com/php-form-not-working.php
browsers show warnings when your action refers to an external source. Some browsers do not post form at all. This is unsafe for users.