Jump to content

Users not adding since upgrade to PHP


RDC

Recommended Posts

PHP was upgraded on my server to PHP 5 and now a script that I had running and working is not doing as it is told. I can't seem to see what the problem is. Can anyone help?

[code]<?php require_once('../Connections/grey.php'); ?>

<?php

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;



  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}



$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

  $editFormAction .= "?" . $_SERVER['QUERY_STRING'];

}



if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

  $insertSQL = sprintf("INSERT INTO users (username, password, realname, email, currency) VALUES (%s, %s, %s, %s, %s)",

                      GetSQLValueString($_POST['username'], "text"),

                      GetSQLValueString($_POST['password'], "text"),

                      GetSQLValueString($_POST['realname'], "text"),

                      GetSQLValueString($_POST['email'], "text"),
 
  GetSQLValueString($_POST['currency'], "text"));



  mysql_select_db($database_grey, $grey);

  $Result1 = mysql_query($insertSQL, $grey) or die(mysql_error());



  $insertGoTo = "adduser.php?msg=ok";

  if (isset($_SERVER['QUERY_STRING'])) {

    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

    $insertGoTo .= $_SERVER['QUERY_STRING'];

  }
echo "<b><font size=2 face=Verdana>User Added Successfully</font></b>";
  //header(sprintf("Location: %s", $insertGoTo));

}



mysql_select_db($database_grey, $grey);

$query_user = "SELECT * FROM users";

$user = mysql_query($query_user, $grey) or die(mysql_error());

$row_user = mysql_fetch_assoc($user);

$totalRows_user = mysql_num_rows($user);

?>

<html>

<head>

<title>Add User</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>



<body>

<p><font face="Arial, Helvetica, sans-serif" size="2" color="#999999"> </font></p>

<table width="95%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#999999">

  <tr>

    <td><table width="100%" border="0" cellspacing="0" cellpadding="2">

        <tr>

          <td bgcolor="#EEEEEE">

<p><font face="Arial, Helvetica, sans-serif" size="2" color="#999999">

              <?php

if ($msg == "ok"){

?>

              </font></p>

            <p></p>

            <table width="90%" border="0" cellspacing="0" cellpadding="4" align="center" height="14">

              <tr bgcolor="#003399">

                <td width="660" height="11" bgcolor="#CCCCCC"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"><strong>Status

                  Message</strong></font></td>

              </tr>

              <tr>

                <td width="660" height="20" bgcolor="#DDDDDD" class="table_outline">

                  <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><strong>OPERATION

                    SUCCESSFUL </strong><br>

                    <br>

                    </font></div></td>

              </tr>

            </table>

            <?php } ?>

            <form method="post" name="form1" action="<?php echo $editFormAction; ?>">

              <table align="center">
                <tr valign="baseline">
                  <td nowrap align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Username:</strong></font></td>
                  <td><input type="text" name="username" value="" size="32"></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Password:</font></strong></td>
                  <td><input type="text" name="password" value="" size="32"></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Real
                    Name:</font></strong></td>
                  <td><input type="text" name="realname" value="" size="32"></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right"><strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Email:</font></strong></td>
                  <td><input type="text" name="email" value="" size="32"></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Region:</strong></font></td>
                  <td><select name="currency" id="currency">
                      <option value="1">US Dollar</option>
                      <option value="2">Euro</option>
                      <option value="3">UK Sterling</option>
  <option value="0">Scottish Water</option>
                      <option value="3">&lt;&lt; Select &gt;&gt;</option>
                    </select></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right">&nbsp;</td>
                  <td><input type="submit" value="Add User"></td>
                </tr>
              </table>

              <input type="hidden" name="MM_insert" value="form1">

            </form>

            <p>&nbsp;</p>

 

            <p>&nbsp;</p>

</td>

        </tr>

      </table></td>

  </tr>

</table>

<FORM>

  <p align="right">

    <INPUT name="Button" Type="Button"

onclick="window.close()" Value="Close Window">

  </p>

</FORM>

<p>&nbsp;</p>

</body>

</html>

<?php

mysql_free_result($user);

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/27049-users-not-adding-since-upgrade-to-php/
Share on other sites

define what you meen by [i]not doing as its told[/i]. You might also try narrowing the problem down a little, Dreamweaver code is hard enough to read without having to sift through a ton of it.

One problem I see is you dont have $msg defined. Change this....

[code=php:0]
if ($msg == "ok"){
[/code]

to...

[code=php:0]
if ($_GET['msg'] == "ok"){
[/code]
[quote author=thorpe link=topic=114762.msg467048#msg467048 date=1163379621]
define what you meen by [i]not doing as its told[/i]. You might also try narrowing the problem down a little, Dreamweaver code is hard enough to read without having to sift through a ton of it.

One problem I see is you dont have $msg defined. Change this....

[code=php:0]
if ($msg == "ok"){
[/code]

to...

[code=php:0]
if ($_GET['msg'] == "ok"){
[/code]
[/quote]

Sorry. I have been getting a little worked up over this and not thinking straight. It just resets the form when submit is pressed. I put all the code in as I wasn't sure what the actual problem was. Thank you for your help, I will change the part that you mentioned and I apologise for just running blindly in and mashing away! I was in a panic.
There is another script that allows me to edit users, in particular the type of currency they use. This is displayed as a number from 0-3. This keeps resetting to 0 each time I press the update button. Everything else is working fine except for this, any ideas?

[code]$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

  $editFormAction .= "?" . $_SERVER['QUERY_STRING'];

}



if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

  $updateSQL = sprintf("UPDATE users SET username=%s, password=%s, realname=%s, email=%s, currency=%s WHERE initnum=%s",


                      GetSQLValueString($_POST['username'], "text"),

                      GetSQLValueString($_POST['password'], "text"),

                      GetSQLValueString($_POST['realname'], "text"),

                      GetSQLValueString($_POST['email'], "text"),
 
  GetSQLValueString($_POST['currency'], "text"),
 
  GetSQLValueString($_POST['initnum'], "int"));


  mysql_select_db($database_grey, $grey);

  $Result1 = mysql_query($updateSQL, $grey) or die(mysql_error());



  $updateGoTo = "supplier.php?msg=ok";

  if (isset($_SERVER['QUERY_STRING'])) {

    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

    $updateGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $updateGoTo));

}



if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

  $updateSQL = sprintf("UPDATE users SET username=%s, password=%s, realname=%s, email=%s, currency=%s WHERE initnum=%s",

                      GetSQLValueString($_POST['username'], "text"),

                      GetSQLValueString($_POST['password'], "text"),

                      GetSQLValueString($_POST['realname'], "text"),

                      GetSQLValueString($_POST['email'], "text"),
 
  GetSQLValueString($_POST['currency'], "text"),

                      GetSQLValueString($_POST['initnum'], "int"));



  mysql_select_db($database_grey, $grey);

  $Result1 = mysql_query($updateSQL, $grey) or die(mysql_error());



  $updateGoTo = "users.php?msg=ok";

  if (isset($_SERVER['QUERY_STRING'])) {

    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

    $updateGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $updateGoTo));

}[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.