Prestashop any input I add is encrypted - php

I have added a <input name=whatever type=hidden> in authentication.tpl in register form so I have some stats(won't get in details)
I read that hidden POST in AuthController.php and then insert it in the database.
Problem is that the value always comes up encoded , something like this:
b40c094ed9549ae0bd311122b034a15c
I tried reading that POST the normal way + trim(Tools::getValue('whatever'));
but the result is the same.
Anyone could help me? Thank you!

You have to give a name to your input, then get by his name.
<input type="hidden" name="my_input" value="b40c094ed9549ae0bd311122b034a15c">
and in php side :
trim(Tools::getValue('my_input'));
if the value is not the good one, try simply with $_POST, try also urldecode, because some input are encoded( like the input named "back"):
urldecode(trim(Tools::getValue('my_input')));

Related

Detect type value fields from post form

I want know, if it´s possible detect when use POST in form, the value of type for each input field.
For example :
<input type="text" name="phone" value="Phone">
<input type="password" name="pass" value="Password">
I can get value and name for each input field, but, ..... how i can show for each field if type it´s text or password, as in this case
This it´s my question, because i can´t find some solution for this, howewer with jquery but no using php for get results from post form, and i need get this using php
Thank´s in advance
No, you don't receive this information. You'll need to find a workaround for what you're trying to achieve.
Just Using PHP you can't do that. You Need to use javascript for that
Instead of direct form submit onclick of submit you can call a javascript function
In that function create a array of json with field type, field name and field value data
Now post JSON data using ajax or javascript XMLHTTP Request to PHP
. .

form type="url" POST to PHP

So I have a form that requires a user to submit their website to a form. Here is the html line:
<input type='url' name='link'>
And I'm using <input type="submit" value="submit" formmethod="post"> to submit the form to a php
And I'm trying to retrieve the values in my php file with:
$link = $_POST['link'];
Why isn't this working? At first I thought it was because I had htmlspecialchars() but it's not coming through without it either. I can't find anything in any google search that even mentions anything related to this kind of problem (with a type="url" form)
What do I need to do to process form data with type of "url" in PHP with a $_POST?
Get your form method to be set to post e.g
<form method=post>,
if you submit the form and in the url in your browser u can see some more inf then be sure 2 check your form method
I think this is wrong,
method="post"
Its only method, not formmethod
Also make sure, you dont have one more for element name with link.

How to submit additional variables alongside form submission?

I have an HTML form that works properly and stores all variables ('firstname', 'lastname', etc.) in the GET array.
At the time of form submission, I need to pass an additional variable in the GET array to let the PHP controller know to display the next set of prompts. Something simple like step=2.
What I tried doing was setting the form action to ?step=2 as well as ?step=2&. But, no matter what I try, the form's variables are all that show up in the URL.
What am I doing wrong? Is this even possible?
You can use a hidden form field in your form:
<input type="hidden" name="step" value="2">
$_SESSION['step'] = 2;
PS: Or a session var XD
Saludos.

How can I populate the fields of a PHP form automatically when the field values are in the url?

I have a have in PHP and I have common fields such as 'Name' and 'Surname'.
Now when the user visits the page e.g. http://www.example.com/form.php the form fields 'Name' and 'Surname' are empty.
I would like to now have a link similar to this http://www.example.com/form.php?name=John
so that when the client hits the link the PHP form will now have the name field already filled with 'John' in it.
I know this can be done in HTML but how can I do it in PHP?
Just to let to know I do not own the PHP form - I just want a link from my website to fill the PHP form (which I do not have control over).
Thanks in advance.
Can be done using $_GET
An associative array of variables passed to the current script via the URL parameters.
e.g.:
<? php
if(isset($_GET['name']))
{
$test = $_GET['name'];
}
?>
<html>
<body>
<form>
<input type="text" name="test" value="<?php if(isset($test)){echo "$test";}?>"/>
</form>
</body>
</html>
Note: code isnt tested or anything.. Also, there are possible security risks with getting values from your URL (can be considered user input), so make sure you are aware of that and how to prevent
You could store that value and then when you're about to output the input fields
you just pass along the stored value.
$name = $_GET['name'];
// ... later on
echo '<input type="text" value="'.$name.'"/>';
By using $_GET superglobal
<input name="name" value="<?php echo !empty($_GET['name']) ? $_GET['name'] : '';?>" />
<input name="surname" value="<?php echo !empty($_GET['surname']) ? $_GET['surname'] : '';?>" />
You can use the get method in php to get the name and make use of it
You can retrive this information by the $_GET["name"] function, or $_REQUEST["name"].
Reserver variables
Be carefull with those operations, you might have validation a/o security problem.
Note: if you are not sure that the "name" variable is set or not, you have to use also the
isset function to test it.
You can use the $_GET superglobal, so your input could look like this:
<input type="text" name="name" value="<?php if(isset($_GET['name'])) { echo $_GET['name']; } ?>" />
The $_REQUEST superglobal does a similar thing but I would just use $_GET.
It looks like everyone's answers here assume you are building the form yourself, which doesn't appear to be the case based on your question.
The thing that you want to do may or may not be possible. If the form accepts certain kinds of parameters in certain ways, you may be able to hook in to that functionality and set it up so that when someone clicks a link on your page, that information gets passed to the other page.
One way forms can accept this information is in the form of a "get" request. With this method, values are passed as part of the url, as in your example: http://www.example.com/form.php?name=John. Assuming your page has access to a php variable called $name, you can create a link from your code to build this kind of url like this:
Sign up!
If the page does not accept get parameters in this way (and I have a hard time imagining that they would), you may have to try other techniques to send along the information (assuming that they will even accept it!). The two other ways I imagine you could do this are by passing the value with "post" or creating a cookie for the page. If you tell us what page you are trying to set up this behavior on, we might be able to examine it and give you a better answer.

How to add data to a specific form element when it sends to mySQL

I'm creating a form where people can enter a code, for example H23J3PW, which corresponds to the end of a URL (say for example's sake youtube.com/watch?=H23J3PW)
When the database is submitted to the database I'd like it to submit as the full URL ie "youtube.com/watch?=H23J3PW". Is there an easy way to do this?
The form code at the moment is:
<label>youtube.com/</label><input class="inputtext" type="text" name="youtube" value=""/>
Thanks in advance, I have searched around but haven't been able to find a solution.
$url = "youtube.com/watch?=".$_POST["youtube"];
Then just use $url in your query. As mentioned in the comment, $_POST could be $_GET if your form is submitted using a GET.

Categories