I have a simple problem which I couldn't solve until now, the problem is when the user asks for rest password, the email is sent correctly except one thing that the email, doesn't contain a Subject. And I want to add the subject but I wasn't able to do it.
here is the postRemind function in my controller:
public function postRemind()
{
$this->reminderForm->validate(Input::only('email'));
switch ($response = Password::remind(Input::only('email'))) {
case Password::INVALID_USER:
return Redirect::back()->with('error', Lang::get($response));
case Password::REMINDER_SENT:
return Redirect::back()->with('status', Lang::get($response));
}
}
and here is my blade :
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h3>Password Reset</h3>
<div>
You have requested password reset. Complete this form: {{ URL::to('password/reset', array($token)) }}
</div>
</body>
</html>
You can pass a closure to Password::remind where you can set the subject.
https://laravel.com/docs/4.2/security#password-reminders-and-reset
public function postRemind()
{
$this->reminderForm->validate(Input::only('email'));
$response = Password::remind(Input::only('email'), function($message)
{
$message->subject('Password Reminder');
});
switch ($response) {
case Password::INVALID_USER:
return Redirect::back()->with('error', Lang::get($response));
case Password::REMINDER_SENT:
return Redirect::back()->with('status', Lang::get($response));
}
}
Related
After several hours of research on google, I have not managed to find a tutorial that shows how to use vue.js to display the result of a sql query (for example SELECT in my case). I come to you because i need to know how i can retrieve and display the data back by the spring findAll () method in an html page with framwork vue.js.
Thank you in advance for your help.
Here is the html file in which I would like to display the data:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>List of school</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="test">
<h1>Result</h1>
<tr>
<td/>ID</td>
<td/>Description</td>
</tr>
<tr v-for="item in panier">
<td>{item.id}</td>
<td>{item.description}</td>
</tr>
</div>
<script src="http://cdn.jsdelivr.net/vue/1.0.10/vue.min.js"></script>
<script>
new Vue({
el: '#test',
data: {
panier: [
{ id: "1", description: "University"},
{ id: "2", description: "high school"}
],
}
});
</script>
</body>
</html>
The problem I do not know how to fill my basket with the data returned by the findAll () method of spring.I specify that this method returns me the data in JSON format. Like this :
{
id:1,
description:"University"
}
{
id:,
description:"University"
}
Here is my getAllType method :
#RequestMapping(value= "/getAllTypes", method = RequestMethod.GET)
public #ResponseBody Collection<Type> getAllTypes() {
return this.typeService.getAllTypes();
}
Please if possible with an example of how I should proceed.
This probably a very simple question, but I can't figure it out alone. I have the following controller:
#RestController
public class TestController extends AbstractCloudController {
private final EquipmentRepository equipmentRepository;
#Autowired
TestController(EquipmentRepository er) {
equipmentRepository = er;
}
#RequestMapping(method=RequestMethod.GET) void index() {
List<String> codes = equipmentRepository.findAllEquipments();
String output = "";
for (String code : codes) {
output += "ID "+code+"\n";
}
}
}
And the following index.html:
<!doctype html>
<html>
<head>
<title>Test Page</title>
<link rel="stylesheet"
href="./bower_components/bootstrap-css-only/css/bootstrap.min.css" />
</head>
<body ng-app="testApp">
<div class="outer">
<h1>Hello World!</h1>
<div class="container">
<div ng-controller="TestController" ng-cloak="ng-cloak">
<p>This is a test page</p>
</div>
</div>
<script src="js/angular-bootstrap.js" type="text/javascript"></script>
<script src="js/hello.js"></script>
</div>
</body>
</html>
How do I get the information from the controller to the server side without it overriding the html? When I make the controller return something, it ends up overwriting the html and printing only the equipment code instead instead of the "Hello World", even the page title doesn't show.
I don't know what do you returned in your controller, but you may check this document: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-return-types
If you want to print the content of output, you may add it to a Model
#RequestMapping(method=RequestMethod.GET, Model model) void index() {
List<String> codes = equipmentRepository.findAllEquipments();
String output = "";
for (String code : codes) {
output += "ID "+code+"\n";
}
model.addAttribute("output", output);
}
then use JSP Expression Language to get the content
${output}
PS. Spring will treat a returned string as view name, not html content by default.
I've code like this, to create/edit Contact form. I need to get some values from model, if I'm editing form, and do nothing, if i'm creating new.
#(fieldForm: Form[MyModel])
#import helper._
#main("Create new") {
#form(routes.Actions.createFieldHolder()) {
<html>
<head>
<script>
function funcOnLoadSubForm(){
#*
if(#fieldForm.get==null) {
...
}
*#
OR
#*
if(#fieldForm.get.equals(null)) {
...
}
*#
OR
#*
if(#fieldForm.get.eq(null)) {
...
}
*#
}
</script>
</head>
<body onload="funcOnLoadSubForm()">
</body
}
I always get an error : IllegalStateException: No value.
The API Documentation states that get will return the concrete value, if the submission was a success.. Since you are creating a new model you haven't submitted anything which means the data is empty and get will throw an exception.
You can fix this by using foreach on fieldForm.value. Example:
<script>
function funcOnLoadSubForm(){
#fieldForm.value.foreach { data =>
// Do something here if fieldForm was submitted
}
}
</script>
I am struggling creating my java coin toss for my webpage. I need to write a Java script to put on the webpage that will show pictures of coins being tossed and carry out the coin toss. here is what I have, why isn't it working? It just opens a new page and says "about:blank?"
<html>
<head>
<title> </title>
<script>
function toss() {
if (Math.random()>.5) {
window.document.coin.src = "heads.jpeg";
}
else {
window.document.coin.src = "tails.jpeg";
}
return false;
</script>
<body>
<img name="coin" src="questionmark.jpeg">
<form action="" onSubmit="return toss() ;">
<input type="submit" value="Toss">
</form>
</body>
</html>
You are missing the closing curly brace for your toss() function. Once fixed it appears to work fine. Also, yes, javascript...not java.
function toss() {
if (Math.random()>.5) {
window.document.coin.src = "heads.jpeg";
}
else {
window.document.coin.src = "tails.jpeg";
}
return false;
}
I'm a bit confused how this work and how to use it. I have a page which is loaded after button is clicked. When the user is deleted I want to back to users.php page. What I tried so far and didn't work is:
<META HTTP-EQUIV="Refresh" Content="2; URL=admin/users.php">
also this:
<META HTTP-EQUIV="Refresh" Content="2; URL=users.php">
I get 404.php error. Files are in same directory. I also have in head this
<base href="http://example.com/app/admins/">
The path to users.php is example.com/app/admins/admin/users.php
Edit: flash session message
userdelete.php
if (isset($_POST)) {
$_SESSION['postIsSet'] = 'Deleted!!';
} else {
$_SESSION['postIsSet'] = false;
}
header('Location: users.php');
In users.php
if (isset($_SESSION['postIsSet'])) {
if ($_SESSION['postIsSet'] == true) {
echo $_SESSION['postIsSet'];
unset($_SESSION['postIsSet']);
} else {
echo "Post is not set - Flash Message";
}
}
else {}
In PHP you can use header() to redirect to other page.
header('Location: http://example.com');
But you can't output anything before headers. Since you want to output some message too, you can use this code:
header("refresh: 2; http://www.example.com/");
echo <<< MESSAGE
<html>
<head></head>
<body>
Some message to show
</body>
</html>
MESSAGE;
It will redirect user after 2 seconds also showing some code. If you need more complex code, you can use ob_* functions to gather any output and later output it.
Flash Message Example
[doStuff.php]
session_start();
if (isset($_POST)) {
$_SESSION['postIsSet'] = true; // or some string
} else {
$_SESSION['postIsSet'] = false;
}
header('Location: http://example.com/user.php');
[user.php]
session_start();
if (isset($_SESSION['postIsSet'])) {
if ($_SESSION['postIsSet'] == true) {
// If you set message in session, you can do `echo $_SESSION['postIsSet'];`
echo "Post is set - Flash Message";
} else {
echo "Post is not set - Flash Message";
}
unset($_SESSION['postIsSet']);
} else {
// Flash message is not set yet.
}
Works fine for me:
<!DOCTYPE html>
<html>
<head>
<base href="http://example.com/app/admins/">
<meta charset="utf-8">
<META HTTP-EQUIV="Refresh" Content="2; URL=admin/users.php">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
Try this it will work :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Refresh" Content="2; URL=http://example.com/app/admins/admin/users.php">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
After I read your comments also if you still whant to use header location instead of refresh here is what you can do. This work fine to me:
In your userDelete.php
header('Location: users.php?msg=deleted');
In your users.php
if(isset($_GET['msg'])){
echo $_GET['msg'];
}
It's work just fine