Any help would be appreciated. I am trying to SSO from our portal using an ASPX page that submits username and password to the form on my PHP login page for another site. I've successfully pulled this off to other pages but can't get it to work now.
This is the block of code from the ASPX page.
case "k": // Kivuto
{
%>
<body onload="document.getElementsByTagName('form')[0].submit()">
<form name="login" action="https://webapps.someschool.edu/sso/kivuto.php" method="post">
<input type="hidden" name="ccid" value="<%=strUser%>">
<input type="hidden" name="passwd" value="<%=strPass%>">
</form>
</body>
<%
break;
This is the block of code from the PHP page.
<form name="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php echo $_error; ?><br />
<p><h2>Some School</h2></p><br />
<p>Username<br />
<input type="text" name="ccid" size="25" /></p>
<p>Password:<br />
<input type="password" name="passwd" size="25" /></p>
<input type="submit" name="submit" value="Log In" />
<input type="reset" name="reset" value="Clear" />
</form>
When I call the case k it does open the kivuto.php page but doesn't auto-submit. I even put a php var_dump ($_POST) in the body and it shows the correct username and password is getting to the kivuto.php page from the ASPX page, just not logging me in.
Any ideas?
Thanks,
Related
<form method="post" action="">
<input type="text" class="form-control" name="name" placeholder="some name">
<input type="text" class="form-control" name="code" placeholder="123456">
<input type="submit" class="btn btn-info" value="Submit" name="submit" />
</form>
<br>
<?php
//submit data
if (isset($_POST['submit'])) {
echo $_POST['name']."<br/>";
echo $_POST['code']."<br/>";
}
?>
that was my index.php and i want to post data into this form from another web page and get response by using php
Set the action-attribute to anotherwebpage.php and catch the values with the $_POST-Variables. So you basically move your PHP-block to anotherwebpage.php.
I have an HTML input and button:
<form action="validate.php" method="post">
<!-- THE CODE INSERT -->
<div id="code">
<form>
<label></label>
<input id="input" name="InputText" type="text"/>
</form>
</div>
<!-- THE BUTTON ITSELF -->
<input type="button" id="button" name="myButton"><b>Search Archive</b>
</form>
in my validate.php file I have this switch statement:
<?php
switch ($_POST["InputText"])
{
case "someval":
http_header("someaddress.com");
die();
break;
}
?>
the problem is that when I click the button it doesn't do anything. I did this with JS and it worked but it should be noted that I'm really new to web development so if anyone can explain to me what I did wrong and specifically why that would be great. Thanks!
You have a form inside of a form, that won't work. Also, you need to include an <input type="submit" value="submit" /> before you close your form. This is what submits the information from the form to your action="file.php".
A form would typically look like this:
file.html
<form action="validate.php" method="POST">
<input type="text" name="username" placeholder="Enter your username" />
<input type="submit" name="submit" value="Submit" />
</form>
Then you'd do something like this:
validate.php
<?php
echo "Your username is" . $_POST['username'];
The $_POST['username'] is the data gathered from the name="username" input from the HTML. If you write die($_POST); you'll get all the data that is sent through the form.
When you are using type='button' you have to perform the submit by yourself.
So, you can do that using javascript or change to type='submit'.
Example:
<input type="button" id="button" name="myButton"><b>Search Archive</b>
To
<input type="submit" id="button" name="myButton" value="Search Archive" />
you can try this
<form action="/validate.php" method="post">
<!-- THE CODE INSERT -->
<div id="code">
<label></label>
<input id="input" name="InputText" type="text"/>
</div>
<!-- THE BUTTON ITSELF -->
<button type="submit" id="button" name="myButton">Search Archive</button>
</form>
in the div id ="code" you used form tag that's why its not work...delete it will work and button type must be submit
hello i have a page where users can register, and so after registeration i want to pass the username and password from my registeration form to another form on a next page, mean while this form on the next page should hold username and password values that are passed from the first page.
the form is echoed correctly but the values dont come correctly.
this is what i ahve tried
echo '<form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" name="one" id="one">
<input type="text" placeholder="Username" name="Username" value="<?php echo $_POST["Username"]; ?>" >
<p> </p>
<input type="password" placeholder="Password" name="Password" value="<?php echo $_POST["Password"]; ?>">
<br>
<input name="Submit" type="submit" class="btn" value="Sign In" />
</form>';
but the values dont come out, is there a right way to echoe this thanks
echo '<form ACTION="'.$loginFormAction.'" METHOD="POST" name="one" id="one">
<input type="text" placeholder="Username" name="Username" value="'.$_POST["Username"].'" >
<p> </p>
<input type="password" placeholder="Password" name="Password" value=".'$_POST["Password"].'">
<br>
<input name="Submit" type="submit" class="btn" value="Sign In" />
</form>';
Try This And Reply
You don't do this with echo, because the echo is just some HTML on the other page. You can also save them.
What you want is a form most likely:
Page 1
<form action="page2.php" method="post">
Name: <input type="text" name="username" /><br />
<input type="submit" name="submit" value="Send" />
</form>
Page2
<?php
echo "Your sent username: ", $_POST['username'];
?>
form.php
<html>
<head>
<title>Welcome to SmartSage</title>
<?php echo validation_errors(); ?>
<body>
<form id='myform' action="" method="POST">
<h5>Username:</h5>
<input type="text" name="username" value="" size="50" />
<h5>Password:</h5>
<input type="password" name="passwd" value="" size="50" />
<h5>Security question:</h5><select name="securityq">
<option value="1">What is your house no?</option>
<option value="2">Who is your fav teacher?</option>
</select>
<input type="text" name="securitya" value="" size="50" />
<br>
<input type="submit" value="Login" id="submit" />  
<input type="button" value="Sign Up!" id="signup" />
</form>
</body>
</html>
This is my current form coding... now my objective is to redirect from this form to signup form when user clicks "signup" button...i hv tried above code but its not working...pls help me
Views folder contains /views/signup.php /views/form.php
Thank you!!
You can do in two ways. You have to redirect to signup page. You can't redirect to view file directly. Here signup is controller name. If yu have your signup in another controller then you have to call as site_url("controller_name/signup"); in below code.
<input type="button" value="Sign Up!" id="signup" />
or remove a tag and call via JS.
<input type="button" value="Sign Up!" id="signup" onclick = "window.location='<?php echo site_url("signup.php"); ?>'" />
I have this form :
<form name="loginform" action="dologin.php" onsubmit="return isValid();" method="post">
<span id="usr">Username:</span><input type="text" style="width:230px;margin-top:10px;" name="username" />
<span id="psw">Password:</span><input type="password" style="width:230px;margin-top:10px;" name="password" />
<input type="submit" name="login" value="Login" class="button about small" style="width:100px;" />
Click to Register!
</form>
And when someone enters the wrong password it will show an error (as expected).
I have this 'if' statement, if($pass == $user['Password']).
And when it returns false it will show the error.
(Notice im only talking about the password validation, the form validation is in JS)
My question is how can I show the error? Make an empty span and then edit it (if it's possible)?
My idea.
consider login.php is your login page with login form.
<form name="loginform" action="dologin.php" onsubmit="return isValid();" method="post">
<span id="usr">Username:</span><input type="text" style="width:230px;margin-top:10px;" name="username" />
<span id="psw">Password:</span><input type="password" style="width:230px;margin-top:10px;" name="password" />
<?php if(isset($_GET['error1'])){?>
<span style='color:#f00'>Passwor or username error</span>
<?php }?>
<input type="submit" name="login" value="Login" class="button about small" style="width:100px;" />
Click to Register!
</form>
And login_sub.php your sub page for check password.
<?php
//Chech username and password
if($pass != $user['Password'])
{?>
<script>
self.location='login.php?error1=1';
</script>
<?php}
?>
By using PHP
consider you are checking the login credentials. If user is not a valid user then store the error string in the variable error.
$error="Invalid username/password";
Then you can include your login page on this page.
include "login.php";
Then on login.php page you put the below condition in a span or div
if(isset($error))
{
echo $error;
}
your work is done.