HTTP POST to web login form. Joomla, INVALID TOKEN - html

I am trying to create a HTTP POST to a joomla web login form for a web page.
I used this before and I am not new to this but I am stumped, I cannot get any response other than 'invalid token'
The purpose of this is to have a POST that I can use for a mobile application to 'remember' the password as a temporary solution.
I HAVE used Charles to check the difference between the HTTP Requests and I see no difference between if I use the login form manually and if I use a POST in the URL
My Request is
http://www.example.com/member-login?task=user.login&username=SECRET&password=SECRET&return=aW5kZXgucGhwP29wdGlvbj1jb21fdXNlcnMmdmlldz1wcm9maWxl&1132a16eb61f5659e8ff62fb935f6037=1
The HTML code is
<form action="/member-login?task=user.login" method="post" class="form-horizontal" name="login_form">
<div class="joomla_login">
<fieldset class="input">
<h2>Login</h2>
<p>Login using the email address and the password that you used when you registered.</p>
<p>
<span class="add-on">
<label id="username-lbl" for="username" class=" required">User Name<span class="star"> *</span></label> </span>
</p>
<div class="controls">
<input type="text" name="username" id="username" value="" class="validate-username required" size="25"/> </div>
<p>
<span class="add-on">
<label id="password-lbl" for="password" class=" required">Password<span class="star"> *</span></label> </span>
</p>
<div class="controls">
<input type="password" name="password" id="password" value="" class="validate-password required" size="25"/> </div>
<div style="text-align: center; padding-top: 20px; padding-bottom: 20px;">
<button type="submit" class="btn btn-primary dummy-button" >Log in</button>
</div>
<input type="hidden" name="return" value="aW5kZXgucGhwP29wdGlvbj1jb21fdXNlcnMmdmlldz1wcm9maWxl" />
<input type="hidden" name="1132a16eb61f5659e8ff62fb935f6037" value="1" /> </fieldset>
</div>
</form>
Thanks in advance

Try this,
In the Joomla installation site , you have to create a external script(file). the access the Framework there with following code.
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
Now you will be able to use all Joomla libraries and functions on the page.
simple check your login details with following codes.
$credentials['username'] = $data['username']; //user entered name
$credentials['password'] = $data['password']; //users entered password
$app = JFactory::getApplication();
$error = $app->login($credentials, $options);
if (!JError::isError($error)) {
// login success
}
else{
//Failed attempt
}
Make sure this script is available in public access so pass any secret key to access only with your additional encrypted parameter.
Hope it helps..

Related

not able to view the JSON format of the data after submitting the form

i am working on angular project where i have to fill the username and password
after submitting the code i have routed to swagger URL but i am not able to get the JSON format data
my form
<!-- HTML code for the login form -->
<form #form="ngForm" id="login-form" (ngSubmit)="addUsers()">
<label for="username">Username:</label><br>
<input type="text" id="username" name="username" [(ngModel)]="addUser.userName"><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password" [(ngModel)]="addUser.userPassword"><br><br>
<input type="submit" value="Submit">
</form>
my typescript
addUsers(){
this.userService.addUser(this.addUser)
.subscribe({
next:()=>
this.router.navigateByUrl("https://localhost:7068/Users")
})
even i added service too check this out
My service
addUser(adduser:User):Observable<User>{
adduser.userName
adduser.userPassword
return this.http.post<User>(this.baseApiUrl+"/Users",adduser)
}
i even tried to route using new component too but i failed please help me out
THANKS IN ADVANCE

Why email js not sending mail when using from react app?

Email js is not sending any email when i am sending from my react app contact us page , though email is working fine when i am testing it from the website itself . here is the code for email js i have used. I have removed the unncessary part.
function Contactme() {
const form = useRef();
function sendEmail(e){
emailjs.sendForm('gmail', 'template_ppq****', form.current, 'iWxx2qNPr0xxu****')
.then((result) => {
console.log(result.text);
}, (error) => {
console.log(error.text);
});
e.target.reset();
}
return (
<div>
<div className="contact-box">
<div className="details">
<h2>Contact</h2>
<p>Fill up the form to contact</p>
</div>
<div className="sendmsg">
<form action="" onSubmit={sendEmail} ref={form}>
<div className="contact-right name-input" name="name">
Your Name
<input type="text" className="contact-right-input email-input" name="from_name" />
Your email
<input type="text" className="contact-right-input message-input" name="email"/>
Subject
<input type="text" className="contact-right-input message-input" name="subject"/>
Your message
<textarea id="" cols="30" rows="10" style={{border:"1px solid lightblue"}} name="message"></textarea>
<button className="contact-btn" >Submit</button>
</div>
</form>
</div>
</div>
</div>
)
}
Add an ID to your input field and ensure the ID is the same with the set up on your Emailjs dashboard. I hope this helps
This is what worked for me. At emailjs.sendForm('gmail'.......... instead of 'gmail' use your service IDthis one

Not going to specific URL this.router.navigate() in AngularJs

I am making a registration form in angularJS and I use the bootstrap template for design.
This is my form and path to the form page is http://localhost:4200/signup
<form method="post" (submit)='register(username.value,email.value,password.value)'>
<div class="form-group">
<label for="name">Full name</label>
<input type="text" id="name" #username class="form-control" placeholder="Enter your name">
</div>
<div class="form-group">
<label for="remail">Email address</label>
<input type="email" id="remail" #email class="form-control" placeholder="Enter email">
</div>
<div class="form-group">
<label for="rpassword">Password</label>
<input type="password" #password class="form-control" id="rpassword" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
But the problem is that it when I click submit button or hit enter, It automatically refresh the page and shows Cannot POST /signup.
As this is my component.ts file
register(name,email,password) {
this.userService.registerUser(name, email, password).subscribe(data => {
if (data.success) {
console.log('reaches');
this.router.navigate(['user']);
} else {
console.log('error');
}
});
}
It is trying to go to the /signup path in post method but in component.ts file I give the path to '/user'
How can it automatically go-to /signup? And how to stop that.
Your form is trying to post data to a server. It sounds like you don't have a server which can handle the post, so you get the error.
To fix the problem, you need a server which can handle the form post.

Form submit is not sending an email

I'm having a problem with hosting24.com and I have a submit form which doesn't seem to be sending the emails no matter what I try.
This is what I've tried
<section id="contact-full-2" class="dark-bg bg-color1 cover-bg" style="background-image:url(images/bg29.jpg)">
<div class="container">
<h2 class="title">Order Service</h2>
<p class="sep-bottom">Paypal will hold the money until both parties agree to full satisfaction.<br>Lets begin! </p>
<form action="scripts/contact.php" role="form" id="contact_form">
<div class="form-group">
<input type="text" class="form-control" id="contact_name" placeholder="Full name" name="name">
</div>
<div class="form-group">
<input type="email" class="form-control" id="contact_email" placeholder="Email Address" name="email">
</div>
<div class="form-group">
<textarea class="form-control" rows="4" placeholder="Your message or question" id="contact_message" name="message"></textarea>
</div>
<button type="submit" id="contact_submit" data-loading-text="•••" class="btn btn-lg btn-block btn-primary">Order</button>
</form>
If you are on localhost the mail will go to a folder named MailOutput. If you are using free hosting most of the hosts disable the mail() function due to its wide misuse. If you are using a paid hosting service and you have't changed the code from its working condition you may have to contact the host provider. It may be due to some server error. Check if any of the above are applicable to you.
According to your reply. This is because you are using a gmail address in the FROM section of your email. Your server does not allow that to prevent fake emails from being send. So you will have to try the following code
<?php
$to = "someone#example.com";
$message = $_POST['message'];
$body = "From: $name_field\n Message:\n $message";
$subject = "Contact";
$name_field = $_POST['name'];
mail($to,$subject,$body);
?>

html help on my contact form please?

I need some help, I'm building a website for a good friend and I need some help with the contact form. I found the code online but it's not working correctly. It sends the e-mail but not all the forms correctly, and doesn't send the picture. Also, when I send the form, it should link to the page contactus.html, but the link doesn't seem to work either. Can anyone help correct this code, this would help SO much. Thank you so, so much.
Here is the HTML for the contact form:
<div id="stylized" class="myform">
<form id="form" id="form" action="mail.php" method="POST">
<label>Name
<span class="small">Add your name</span>
</label>
<input type="text" name="name">
<label>Address
<span class="small">Add your home address</span>
</label>
<input type="text" name="address">
<label>Phone
<span class="small">Add a Phone Number</span>
</label>
<input type="text" name="phone">
<label>E-mail
<span class="small">Enter a valid E-mail</span>
</label>
<input type="text" name="email">
<label>Timeline
<span class="small">Range for your project</span>
</label>
<input type="text" name="timeline">
<label>Photo
<span class="small">Upload current picture</span>
</label>
<input type="file" name="photo">
<label>Description
<span class="small">Type Your Project Description</span>
</label>
<textarea name="message" rows="6" cols="25"></textarea>
<button type="submit" value="Send" style="margin-top:15px;">Submit</button>
<div class="spacer"></div>
</form>
</div>
And here is mail.php, which is supposed to help make the form work. I think here is where the problem is:
<?php $name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$timeline = $_POST['timeline'];
$description = $_POST['description'];
$formcontent="From: $name \n Message: $message";
$recipient = "blanger#hawaii.edu";
$subject = "New Project Request from 2DadsDB.com";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='contactus.html'>Go Back</a>";
?>
As Blender pointed out the code is very insecure. It's easy for malicious content to be inserted. Also there's no reference in the mail.php to "photo"
$fileImage = $_POST['photo'];
You'll need to use a script to upload and store the photo I believe. It's best too look at a tutorial or complete source instead of building from scratch.
The mail() function is good for only message sending.
To send an image First you need to upload your photo to the server To upload an image.
To send an image using mail() first attach your photo from server to mail() PHP e-mail attachment script
And use $name = mysql_real_escape_string(strip_tags($_POST['name']));
for each post like name,e-mail etc., for security purpose.
You should sanitize your imputs.Use mysql_real_escape_string or stripslashes function on each of the $_POST.
$user = mysql_real_escape_string($_POST['user']);