Concatenating strings retrieved from form $_Post in php - php

I am posting a string through an HTML form with the following code:
<html>
<body>
<form name="form" enctype="multipart/form-data" action="test.php" method="post">
<input name="message"
type="text" value=""><br/><br/>
<input type="submit" value="Upload"/><br/>
</form>
</body>
</html>
The code for test.php is the following:
<?php
$string1 = '$_POST["message"]';
$og_url = "http://thepropagator.com/facebook/testapp/issue.php?name=".$string1;
echo $og_url;
?>
The problem I'm having is that the posted string "$string1" does not seem to be showing at the end of the URL "http://thepropagator.com/facebook/testapp/issue.php?name=" that I am trying to concatenate it with. Can anyone please explain what I'm doing wrong?

I think you want $string1 = $_POST['message'];, no quotes. Though I'd expect your code to come up with http://thepropagator.com/facebook/testapp/issue.php?name=$_POST["message"] url.

Related

Get variable from Post Data (PHP)

I really don't know why my code isn't working! Let me clear it by example..
I got a file named 'index.html' example...
<html>
<body>
<form action="test.php" method="post">
Name: <input type="text" name="test">
<input type="submit">
</form>
</body>
</html>
And of course the form action file test.php .. example..
<?php
$something = ($_POST["test"]);
// from here I have some PHP codes and this "something" variable will be process in this codes and will print out something spacial..
?>
Now example If I post "Hello, It's not working" then the output will show a spacial design.
But Instead process, it's just printing out whatever I submit in that form.
But when I manually add the variable to "something" and if I execute the "test.php" . Example..
$something = "Hello, It's not working";
Then it works perfectly..
And yes. Also tried GET method.. It's still same as POST.
This is my first question here..
Thanks for any help and suggestions!
First Convert, index.html to php and follow this code:-
<html>
<body>
<form action="test.php" method="post">
Name: <input type="text" value="" name="test">
<input name="submit" value="submit" type="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])){
$something = $_POST["test"];
}
?>
That's correct _POST:
<?php
//NO ($_POST["test"])
$something = $_POST["test"];
?>

How to acess form details in php page using html 'id' attribute

i have a form having employeeNo,name and a submit button. when the form is submitted it redirects to a php page, Now the problem is i want to access the values of the form by using 'id' attribute?if possible i need the html and php code.
Is there a way to solve this Problem?
enter code here<html>
<head>
</head>
<body>
<form action="test.php" method="">
<input type="text" name='employeeNo' id="input1">
<br>
<input type="text" name='name' id="input2">
<br>
<input type="submit" id="input3">
</form>
</body></html>
In your test.php file you need to retrieve the values. Since you don't define any method in your form, by default it should be "GET"
Your php file could look like the following:
<?php
$employee_no = $_GET['employeeNo'];
$name = $_GET['name'];
I would suggest defining your form method as POST though, like the following:
...
<form action="test.php" method="POST">
...
so your php file will retrieve values from form like this:
<?php
$employee_no = $_POST['employeeNo'];
$name = $_POST['name'];
You may also look at this for further explanation:
https://www.w3schools.com/php/php_forms.asp

Getting post data from form with iframe doesn't work PHP

I have this code:
<!DOCTYPE html>
<html>
<body>
<iframe name="votar" style="display:none;"></iframe>
<form id="excel form" method="post" target="votar">
<input type="submit" name="test" id="test" value="RUN" /><br/>
</form>
</body>
</html>
<?php
if(isset($_POST['test']))
{
echo "hello world";
}
?>
what am I trying to do? well I try to get hte post data from this form without reloading the page and without using ajax, but what am I doing wrong? I tried looking around, but all the other solutions are to long or just not prectical for my website. please help.
EDIT
just changed submit to test, doesn't matter.
<form action="" method="post" >
<!-- code -->
</form>

PHP form not sending data to $_POST

<!DOCTYPE html>
<html>
<body>
<form action="test.php" method="post">
<input name="test" type="text">
<input type="password" name="data">
<input type="submit">
</form>
</body>
</html>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$name = $_POST['test'];
$pass = $_POST['data'];
}
?>
I am trying to make a simple form in PHP that users will use for login. When using this code, nothing ever gets put inside the $_POST. I am debugging using PHPstorm and I can tell that the request method is definitely POST, but no data is getting passed through. What am I doing wrong?
Try adding a slash at the begening of the action parameter of the form tag.
<form action="/test.php" method="post">
Try to remove "action" from form. It worked for me.
Code: http://nimb.ws/6pXjnz
Output:http://nimb.ws/PvuxZs

Cannot submit HTML form using PHP on iPad

Recently I got this problem that I cannot solve. My HTML form cannot be submitted by using iPad, but the same form CAN be submitted from my laptop (windows machine). Please check this out:
http://www.gomap.ch/admin/pages/test.php - this is submitted correctly
http://ipadpreview.com/previewer?url=www.gomap.ch/admin/pages/test.php - this is not submitted.
This is a very simple form, and code goes like this:
<?php
error_reporting(0);
if($_POST['mirko']){
echo 'hello, Mirko';
}
?>
<form action="" method="POST">
<input type="submit" value="Submit" name="mirko"/>
</form>
Any help, please??
Thanks a lot!
You are not using valid html.Replace your code with this and have u tried on real ipad.
<html>
<head></head>
<body>
<?php
error_reporting(0);
if($_POST['mirko']){
echo 'hello, Mirko';
}
?>
<form action="" method="POST">
<input type="submit" value="Submit" name="mirko"/>
</form>
</body>
</html>
You need to add the name of the form which holds the php code into the action. In this case it would be the same form you're on. Follow what I did below with nameOfFile.php being the name of the file you posted.
<?php
error_reporting(0);
if($_POST['mirko']){
echo 'hello, Mirko';
}
?>
<form action="nameOfFile.php" method="POST">
<input type="submit" value="Submit" name="mirko"/>
</form>

Categories