2l8vsan Posted November 30, 2013 Share Posted November 30, 2013 I have two pages. A login.html and a check.php page to check the credentials of somebody logging in to my site. My HTML (omitted body etc): <form action = "check.php" METHOD = "post" > <label>username<input type = "text" name = "username" size = "25" maxlength = "30" /></label><br /> <label>password<input type = "password" name = "password" size = "25" maxlength = "30" /></label><br /> <input type = "submit" class = "button" value = "Submit" /> check.php page <?php session_start(); $user = $_POST['username']; $pass = $_POST['password']; echo $user; ?> <p>Hello <?php echo $user; ?></p> <p>Goodbye <?php echo ("$password"); ?></p> <label><a href = "Login.html" name = "login">Go back there</a></label> </body> </html> I have apache running under XAMPP. I can't even see the values pass over. It just shows the HTML. Am I doing something wrong? I had it working earlier. Above is just echo statements attempting to get some value passed over. But I get nothing. Link to comment https://forums.phpfreaks.com/topic/284408-having-trouble-passing-values-from-html-page-to-php-page/ Share on other sites More sharing options...
Barand Posted November 30, 2013 Share Posted November 30, 2013 $user = $_POST['username'];$pass = $_POST['password'];echo $user;?> <p>Hello <?php echo $user; ?></p> <p>Goodbye <?php echo ("$password"); ?></p> As you can see from the highlighting, you store in $pass then echo $password. However, $user should echo. Also, there should be no whitespace before the opening <?php tag otherwise session_start() will fail. Link to comment https://forums.phpfreaks.com/topic/284408-having-trouble-passing-values-from-html-page-to-php-page/#findComment-1460777 Share on other sites More sharing options...
aysiu Posted November 30, 2013 Share Posted November 30, 2013 Are you sure the POST data is even being set? Before this bit $user = $_POST['username']; $pass = $_POST['password']; echo $user; Try putting in this if(isset($_POST['username'])){ echo '<p>There is a username set, and it is ' . $_POST['username'] . '</p>'; } else { echo '<p>There is no username set.</p>'; } Link to comment https://forums.phpfreaks.com/topic/284408-having-trouble-passing-values-from-html-page-to-php-page/#findComment-1460782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.