Jump to content

[SOLVED] Help with script and installation of PHP5.3 on windows.


Recommended Posts

I have bought a book to learn PHP.  I have got to the database bit and can't get any further because I think there is something wrong with the installation.

 

Here is the code I copied from the book and modified a bit.  It is a webform where somebody creates a user id and the user id info gets written to a mysql database.  When I run it on apache, nothing happens at all.  I press the submit button and nothing!! no error message, it just does nothing. 

 

When I change the mysql login name to one that doesn't exist, it should die, but it doesn't.  But if I miss out a ; or { then I get an error message, so it must be reading the script.

 

<html>
<title>TITLE</title>
<head>
<style type="text/css">@import url(styles/forms.css);</style>
</head>
<body>

<body background="images/bg2.gif">
<br>
<center>
<table width = "85%" border="1" bgcolor="white" cellpadding="20">
<td style="background:url('images/scales2.gif') 50% 50% no-repeat;">

<center><h1>Create User ID</font></h1>
<img src="images/image.gif"><br>

<?php

if (isset($POST['submit'])) {
    $mysqli = new mysqli("localhost", "user", "password", "user");
    if ($mysqli === false) {
      die("ERROR: Could not connect to database. " . mysqli_connect_error());
    }

// open message block
echo '<div id="message">';

// retrieve and check input values
$inputError = false;
if (empty($_POST['username'])) {
  echo 'ERROR: Please enter a User ID';
  $inputError = true;
} else {
   $username = $mysqli->escape_string($_POST['username']);
}

if ($inputError != true && empty($_POST['password'])) {
  echo 'ERROR:  Please enter a password';
  $inputError = true;
  } else {
    $password = $mysqli->escape_string($_POST['password']);
     }

  if ($inputError != true && empty($_POST['email'])) {
  echo 'ERROR:  Please enter an email address';
  $inputError = true;
  } else {
   $email = $mysqli->escape_string($_POST['email']);
  }
  $date= date("Y-m-m", mktime());
  //add new user to database

  if ($inputError != true) {
  $sql = "INSERT INTO Users (username, password, rating, postnum, threadnum, joined, active, email)
         VALUES ($username, $password, Beginner, 0, 0, $date, n, $email)";
   if ($mysqli->query($sql) === true) {
      echo 'Your ID has been created, you can now log in' . $mysqli  ->insert_id;
  }else {
   echo "ERROR: Could not execute query: $sql. " . $mysqli->error;
  }
}

// close message block
echo '</div>';

// close connection
$mysqli->close();

}

?>

</div>

<form action="createid.php" method="POST">
  Username:  <input type="text" name="username" size="20" />
  <p/>
  Password:  <input type="password" name="password" size="20" />
  <p/>
  Email Address (for verification):  <input type="text" name="email" size="100" />
  <p/>
  <input type="submit" name="submit" value="Submit" />
</form>

</center>
</td>
</table>
<br>
</center>
</body>
</html>

 

I am on day 2 now of trying to work out what is wrong and I think it has something to do with:

 

In the book it says, when installing PHP find the php.ini file and

alter extension_dir = "./" to read

extension_dir = "c:\php\ext\"

and remove the ; from

extension=php_pdo.dll

extension=php_sqlite.dll

extension=php_mysqli.dll

extension=php_pdo_sqlite.dll

extension=php_pdo_mysqli.dll

 

But, two of these lines are not even in the php.ini file and the .dll files are not even in the ext folder.  The missing lines are

extension=php_pdo.dll

extension=php_pdo_mysqli.dll

and the corresponding dll files are missing from ext folder.  Does the program not working have anything to do with this?  I have checked the db and no fields have been updated.

 

First thing's first, you need to be properly set up with all extensions that you are going to be using.  To settle some confusion:

 

But, two of these lines are not even in the php.ini file

 

Add them.

 

and the .dll files are not even in the ext folder.

 

Download your extensions here, PECL, and put them in your extension directory.  Make sure you restart Apache.  You can run a script with just:

 

phpinfo();
?>

 

to view all the extensions that have been installed.  When you have all that working then come back with your relevant code and the entire error messages.

I've updated the PHP config file and run that info program.  All the dll's come up on the table ,like Mysqli comes up with a table reporting cache and things.  So looks as if everything is running ok.

 

But still nothing happens when I press submit.

 

 

Yes!! that is it, that is what has caused all this.  Now I have error messages, thanks for your help.  Will be back for more soon.  I'll take back the yay! from my earlier post, because missing the $POST  for 2 days is definitely not a yay it is something else.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.