Symfony2 The CSRF token is invalid [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I have a problem with Symfony. When I submit the FOSUserBundle register form on the built-in Symfony server (on the port :8000), it shows the error below:
"The CSRF token is invalid. Please try to resubmit the form."
But, when I submit form on Apache server (by /web/app_dev.php/), all works fine.
Hidden token input exists in form.

Your session could be invalid, after it timed out or due some changes in your code.
You need to clear the server and browser cache, then it should work again.

Related

Image Source to Include a PHP Input [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to create an image that changes dependent on the genre grabbed from an icecast server, I am pretty sure I have the base code correct I think I've just incorrectly inputted the PHP variable.
<?php
$stats = $core->radioInfo( "http://http://sc.onlyhabbo.net:8124/status-json.xsl" );
?>
<img src=http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif/>
is the full code. Have I inputted the PHP variable incorrectly
Where are the quotes in your Html?
<img src="http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif"/>
UPDATE EVERYBODY
This is now resolved, I decided to go down the CURL route for this, and at first it didn't work until my host raised our CloudLinux Process Limit. I am unsure what the actual issue with this code was, but the CURL route works fine. Thank you for any answers

Calling a PHP variable through button onclick [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
The goal is to call the variable $url when the button is clicked. With this current bit of code, when the button is clicked nothing happens and the error says unexpected token.
<?php
$url = "edit_beginningcakephp.php?title=$title&author=$author&isbn=$isbn
&year=$year&pages=$pages&price=$price";
>?
<input type="button" value="Edit Book" onclick="window.location.href='<?= $url ?>'">
I suppose you're not correctly encoding the content of the variables (known as XSS)
You need to urlencode the content of your variables. Also, & needs to be entered as an HTML entity &.
Try:
$url = 'edit_beginningcakephp.php?title='.urlencode($title).'&author='.urlencode($author).'&isbn='.urlencode($isbn).'&year='.urlencode($year).'&pages='.urlencode($pages).'&price='.urlencode($price);
PS: >?should be ?> and make sure the URL doesn't contain any newlines.
" >? "
That looks like it might be a problem, definitely throws a syntax error on my local :)
While MrTux's answer is very good and his advice should surely be followed, the actual problem with your code is the return in the URL. URLS can't contain returns!
Solution: delete the return. And the spaces. And follow MrTux's advice.

Make the products stay in the cart after logging out [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I logged in, added products to the cart and then I logged out (I haven't made the payment yet). The cart is empty after logging in again because I use session_destroy in logout.php.
Is it possible to make the products stay in the cart even after logging out? If so, how?
Yes it is possible. Instead of using session_destroy() in logout.php. You can just unset user login specific values like unset($_SESSION['user_id']) or the values you are using for logged in user identification.

Where's my issue here? (PHP/PDO) - User exist [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
trying to check whether a user exists or not via pdo
$wantedusrnm = $_POST['new-usrnm'];
$userExist1 = "SELECT * FROM users WHERE username=:wantedusrnm";
$userExist = $handler->prepare($userExist1);
$userExist->execute(array(':username' => $wantedusrnm));
$userExist = ($userExist->rowCount());
for some reason it errors, dunno why, any reasons?
Change:
$userExist->execute(array(':username' => $wantedusrnm));
To:
$userExist->execute(array(':wantedusrnm' => $wantedusrnm));
Because, in your query you've got :wantedusrnm but in your execution array you've got :username.

Login Functionality not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
So I took the login script demonstrated in this tutorial: http://www.9lessons.info/2014/07/ajax-php-login-page.html
However, when I try to run it, I keep getting an incorrect login information error. The database, the table, all of that is correct. I'll look at it again, but I'm sure that's fine.
I haven't changed anything besides the name of the table, and my db info.
Why does the PHP dissapear? Solved
the php at the top of index.php goes away when I look at the source code on a browser
This is a good thing :)
PHP code is processed server-side. The result of that code (which is usually HTML) is then sent to the browser. PHP code itself should never be sent to the browser for a couple of reasons:
It would expose your server-side code to users, which could help them do malicious things.
The browser wouldn't know what to do with it.

Categories