1

I have a Google App Engine application (php website) with a Cloud SQL Instance database connected to it. First of all my app.yaml is:

application: applicationid
version: 1
runtime: php
api_version: 1

handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css))
 static_files: \1
 upload: (.*\.(gif|png|jpg|ico|js|css))

 - url: /dbconn.php
 script: dbconn.php

 - url: /logincheck.php
 script: logincheck.php

 - url: /loginsuccess.php
 script: loginsuccess.php

 - url: /register.php
 script: register.php

 - url: /sign.php
  script: sign.php

  - url: /viewcurrent.php
  script: viewcurrent.php  

 - url: /.*
  script: mainpage.php

I have the following login form on the mainpage:

  <form method="post" enctype="application/x-www-form-urlencoded" action="logincheck.php" autocomplete="off" >
   <table>
    <tr>
    <td><label for="username">Username</label></td>
    <td><input type="text" name="username"></input></td>
    </tr>
    <tr>
    <td><label for="password">Password</label></td>
     <td><input name="password" type="password"></input></td>
     </tr>
     <tr>
     <td><input type="submit" value="Submit"</td>

And logincheck.php is:

  <?php
  session_start();

 require "dbconn.php";

 $username = $_POST['username'];
 $password = $_POST['password'];

  $query = "SELECT * FROM students WHERE username = '".$username."' 
  AND password = '".$password."'";

 $result = $connect->query($query);

 $row = $result->fetch_assoc();

 if ($row != null)
 {
$_SESSION['username'] = $username;
header("Location: loginsuccess.php");

exit();
 }
 else
 {
 header("Location: wrongdetails.php?showerror=1");
 exit();
 }
 ?>

So the user is then suppose to be sent to 'loginsuccess.php' when they have logged in. I have the correct database set up on Cloud SQL with the correct fields, such as username and password. But when the user types in the correct username and password the page just reloads exactly the same but with the url:

http://localhost:8080/logincheck.php

Instead of actually doing the actions in 'logincheck.php'

Any ideas of what I'm doing wrong?

Tom
  • 51
  • 1
  • 1
  • 5
  • [You are at risk for SQL Injection.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) Please add some error checking to your database interactions and add error reporting to the top of your file(s) right after your opening `` tags. Your submit tag is incomplete and needs to be closed. – Jay Blanchard Mar 18 '15 at 19:23
  • Are you getting any errors? – Jay Blanchard Mar 18 '15 at 19:46
  • Well I just rearranged the app.yaml file and now get the following error for the logincheck.php (the code shown is the whole file there is nothing else): Warning: session_start(): Cannot send session cache limiter - headers already sent on line 3 Warning: Cannot modify header information - headers already sent by on line 20 – Tom Mar 18 '15 at 19:57
  • The session *must* be started before any output occurs. Did you add the rest of the error checking? – Jay Blanchard Mar 18 '15 at 19:58
  • I have managed to fix the first error. But the second error is still there. Because of the header, but I need that there to send the user to the correct page once the form has been filled in and sent – – Tom Mar 18 '15 at 20:07

0 Answers0