I have a form that the user has to input number contract and a code like so:
<form action="index.php?option=com_platiniumchristmas&cartao=<?php echo $_GET['cartao']?>&contrato=contract&codigo=code" method="post">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-user tip" title="Utilizador"></i>
</span>
<input autocomplete="off" type="text" name="contract" id="contract" class="input form-control" tabindex="0" size="18" placeholder="Num. Contrato" required="" value="">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-lock tip" title="Senha"></i>
</span>
<input autocomplete="off" type="password" name="codigo" id="code" class="input form-control" tabindex="0" size="18" placeholder="Codigo" required="" value="">
</div>
</div>
<input type="hidden" name="cartao" id="cartao" value="<?php echo $_POST['cartao']?>"/>
<input type="submit"value="Login" id="submit" class="btn btn-info pull-right" />
</form>
I have to post those values into an url so that the other page recives this values. But what is happing is instead of putting the id on my form action url it does nothing. Can any one help me with this issue.
The Hidden field is to call a function inside of a the form like so:
<?php
function validateUser($contrato, $codigo)
{
$url = 'http://managerexternal.medicare.pt/MedicareManager_External.svc?wsdl';
$client = new SoapClient($url);
$paramsMC = array('schema'=>'mctestes','numcContrato'=>$contrato, 'codigo'=>$codigo);
$paramsGC = array('schema'=>'gctestes','numcContrato'=>$contrato, 'codigo'=>$codigo);
if($client->AuthenticatedUserByContratoCodigo($paramsMC) == true){
$controller = new getInfoContact();// Instanciar Class
$controller->getuserInfo('mctestes',$contrato);
$_GET['schema']="mctestes";
$controllerNumeroCartao = new getInfoContact();// Instanciar Class
$_POST['cartao']=$controllerNumeroCartao->getNumCartao('mctestes',$contrato);
}
?>
I need to a function to get value for "cartao". Then I need to send through an url the contact and code value that where set by the user. With does two values I call a function to get the users "cartao".
First of all your code is wrong
<form action="index.php?option=com_platiniumchristmas&cartao=<?php echo $_GET['cartao']?>&contrato=contract&codigo=codigo method="get">
should be
<form action="index.php?option=com_platiniumchristmas&cartao=<?php echo $_GET['cartao'];?>&contrato=contract&codigo=codigo" method="get">
Related
I am very new to php and am still in the learning phase. I typed a small script 1 to 1 and had to find out that the index from my HTML file is not recognized in php. In the given video the "GET" method is used, but it should actually work exactly the same way. It is just a test script. Nevertheless, an answer would be helpful.
Here are my scripts:
HTML:
<form id="register-form" action="Memeon.php" method="post">
<img class="register_avatar" src="pictures/login_register_avatar.png" oncontextmenu="return false;">
<h2>Welcome to Memeon</h2>
<div class="reg-input-div one">
<div class="i">
<i class="fas fa-user"></i>
</div>
<div>
<h5>Username</h5>
<input id="reg_un" class="reg-input" name="username" type="text" autocorrect="off" autocapitalize="off" spellcheck="false">
</div>
</div>
<div class="reg-input-div two">
<div class="i">
<i class="fas fa-at"></i>
</div>
<div>
<h5>Email-Adress</h5>
<input id="reg_ea" class="reg-input" name="email" type="email" autocorrect="off" autocapitalize="off" spellcheck="false">
</div>
</div>
<div class="reg-input-div three">
<div class="i">
<i class="fas fa-lock"></i>
</div>
<div>
<h5>Password</h5>
<input id="reg_pw" class="reg-input" name="password" type="password" autocorrect="off" autocapitalize="off" spellcheck="false">
</div>
</div>
<a id="rl_l1" href="#">2-Factor-Authentication</a>
<a id="rl_l2" href="#">Forgot Password?</a>
<input type="submit" onclick="setRegisterInfo()" class="register_btn" value="Sign in">
</form>
PHP:
<?php
echo "Hallo ". $_POST["username"];
?><br>
Der sehnlichst erwünschte Newsletter wird gesendet an <?php echo $_POST["email"]; ?>
Both are in the same folder. With a submit button I get to the PHP page. An error always appears there.
Maybe it haves to be with something in your "setRegisterInfo()" function (is it implemented ? if so, you should post it here too :) ) in the "onclick" attribute of the submit input at the very end. If that function breaks, the form won't be submitted.
<input type="submit" onclick="setRegisterInfo()" class="register_btn" value="Sign in">
Try again without that function.
<input type="submit" class="register_btn" value="Sign in">
i have a foreach row that displays the "message icon" (i dont think it has anything to do with the form since the form is outside the loop:
enter image description here
which displays a chat form that you can either type a chat or send an attachment:
enter image description here
How can i make one of them required before submission? I tried through multiple JQuery ways but because they are in a for loop and each of them do not have a special id, its not working. any help please? I just need it to show an alert
Here is my code for the form:
<form method="post"action="<?php echo base_url();?>form_support_chat" enctype="multipart/form-data" class="ticket-reply-form">
<div class="row">
<div class="col-xs-12">
<div class="chat-left">
<input type="text" name="message" placeholder="Type Message ..." class="form-control" autocomplete="off">
<input type="hidden" name="cst_id" value="<?php echo $cst_id; ?>">
<input type="hidden" name="arch_ticket" value="<?php echo $arch_ticket; ?>">
<input type="hidden" name="ticket_number" value="<?php echo $ticket_number?>">
</div>
<div class="chat-right">
<label>
<img src="<?php echo base_url();?>/assest/icon-img/paperclip.png" class="ic_img" >
<input type="file" name="file" class="form-control" style="display:none;" id="hidden_upload_file_chatting">
</label>
<button type="submit" class="btn btn-flat" name="reply" value="reply" >Reply</button>
<button type="button" class="btn btn-flat" data-dismiss="modal" style="margin-left: 10px !important;">Close</button>
<span id="_showName"></span>
</div>
</div>
</div>
</form>
Simply use html5's required value
<input name="cst_id" value="<?php echo $cst_id; ?>" required>
or
<input name="cst_id" value="<?php echo $cst_id; ?>" required="true">
update
Using jQuery, add id value to each input
$(document).ready(function() {
if( $('#input1').valid() || $('#input2').valid(); ):
console.log("Success");
endif;
});
I created an HTML form that passes variables to an exec_shell. Everything worked perfectly until I added CSS to my HTML page. The new HTML+CSS code doesn't pass the variables to the php shell_exec.
Before (working):
<body>
<form action="adduser.php" method="post">
Server: <input type="text" value="<?php echo $name; ?>" name="name"><br>
Password: <input type="text" value="<?php echo $password; ?>" name="password"><br>
<input type="submit">
</form>
</body>
After (not working):
<form action="adduser.php" method="post" class="contact3-form validate-form">
<span class="contact3-form-title">
Title
</span>
<div class="wrap-input3 validate-input" data-validate="Server Name is required">
<input class="input3" type="text" value="<?php echo $hosts; ?>" name="hosts" placeholder="Server Name or Server Group">
<span class="focus-input3"></span>
</div>
<div class="wrap-input3 validate-input" data-validate = "Valid Password is required">
<input class="input3" type="text" value="<?php echo $password; ?>" name="password" placeholder="Your Password">
<span class="focus-input3"></span>
</div>
<div class="container-contact3-form-btn">
<button class="contact3-form-btn">
Submit
</button>
</div>
</form>
I also tried:
value="<' . $hosts .'"
Is there a better way to do it than HTML ?
Thank you.
your button don't have type="submit"
I have a form in HTML with some checkboxes and I want to send an email with the selected checkboxes in the body, the problem is that the "text" fields are passing to the PHP variables, but the checkboxes values are always set to uncheck when I test it on the PHP file:
HTML:
<div class="col-md-6">
<div class="c-checkbox-list">
<div class="c-checkbox">
<input type="checkbox" name="checkbox1citadina" id="checkbox1citadina" value="checkbox1citadina" class="form-control c-check" >
<label for="checkbox1citadina">
<span></span>
<span class="check"></span>
<span class="box"></span> Citadina
</label>
</div>
PHP:
$reservas_bicicletas = '';
if (isset($_POST['checkbox1citadina'])) {
$reservas_bicicletas .= "Citadina: checked\n";
} else {
$reservas_bicicletas .= "Citadina: unchecked\n";
}
echo $reservas_bicicletas;
$reservas_bicicletas always retrieves the else value.
Need help guys, thanks in advance.
remove c-check
<div class="col-md-6">
<div class="c-checkbox-list">
<div class="c-checkbox">
<input type="checkbox" name="checkbox1citadina" id="checkbox1citadina" value="checkbox1citadina" class="form-control " >
<label for="checkbox1citadina">
<span></span>
<span class="check"></span>
<span class="box"></span> Citadina</label>
</div>
Basically i have this (i shorted out the form because there are too many elements):
HTML:
<form name="quick_booking" id="quick_booking" method="post" action="assets/reserva-bicicletas.php">
<div class="col-md-6">
<div class="c-checkbox-list">
<div class="c-checkbox">
<input type="checkbox" name="checkbox1citadina" id="checkbox1citadina" value="checkbox1citadina" class="form-control " >
<label for="checkbox1citadina">
<span></span>
<span class="check"></span>
<span class="box"></span> Citadina</label>
</div>
<button type="submit" class="btn c-theme-btn c-btn-uppercase btn-lg c-btn-bold c-btn-square">Reservar</button>
</form>
I have a website with two form authentication in different pages, have different input name and link to different pages . The problem is that when I save my authentication to a browser (chrome) of a form , the browser fill in the fields with the same data in the other form . How is it possible?
First form
<form action="" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleInputEmail1">Email</label>
<input type="email" name="private_email" class="form-control" id="email1" value="" placeholder="Enter email" required>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" name="private_password" value="" id="password1" placeholder="Password" required>
</div>
<input type="submit" name="login" class="btn btn-default" value="Login">
</form>
Second Form (It is a form of a cms)
<form action="http://escuolainsieme.it/shop/login" method="post" id="login_form" class="box">
<h3 class="page-subheading">Sei già registrato?</h3>
<div class="form_content clearfix">
<div class="form-group form-ok">
<label for="email">Indirizzo email</label>
<input class="is_required validate account_input form-control" data-validate="isEmail" type="text" id="email" name="email" value="">
</div>
<div class="form-group">
<label for="passwd">Password</label>
<span><input class="is_required validate account_input form-control" type="password" data-validate="isPasswd" id="passwd" name="passwd" value=""></span>
</div>
<p class="lost_password form-group">Hai dimenticato la password?</p>
<p class="submit">
<input type="hidden" class="hidden" name="back" value="my-account"> <button type="submit" id="SubmitLogin" name="SubmitLogin" class="button btn btn-default button-medium">
<span>
<i class="icon-lock left"></i>
Entra
</span>
</button>
</p>
</div>
</form>
Login.php
<?php session_start(); // Starting Session
$error = ''; // Variable To Store Error Message
if (isset($_POST['private_login'])) {
if (empty($_POST['private_email']) || empty($_POST['private_password'])) {
$error = "<div class='alert alert-danger'>Compila tutti i campi</div>";
} else {
$email = mysqli_real_escape_string(conn(), $_POST['private_email']);
$password = mysqli_real_escape_string(conn(), $_POST['private_password']);
$cls_utente = new utente();
if ($cls_utente->check_user($email, $password) == 1) {
$_SESSION['login_user'] = $email; // Initializing Session
$_SESSION['is_logged'] = true;
} else {
$error .= "<div class='alert alert-danger'>Email o password errati</div>";
}
}}?>
You can try using autocomplete="false" or autocomplete="off" to disable it, not sure if it will work but give it a try.
As far as i am concerned it's not possible to make the browser 'realize' that they are different forms and they should not be auto-filled with the same data.
Have a look at these 2 answers, answer1 answer2 for more information how browser detects the forms.
You must add another one column in your user table, example if you add type column the value set default super admin,moderator, user. Now you can check the login authentication with this column.If user-name and password and type is equal redirect to particular page.so you can redirect different page depends upon the user type..