4 Replies - 433 Views - Last Post: 06 July 2013 - 03:20 AM

#1 Mause  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-July 13

Code not working for Firefox or Internet Explorer?

Posted 03 July 2013 - 10:55 PM

http://pastebin.com/ysEXKHXk
<center>
<body bgcolor="#ECE9E0">
<?php
session_start();
 
require_once( 'inc/config.inc.php' );

error_reporting(E_ALL & ~E_NOTICE);

$url = $_SERVER["HTTP_HOST"]; 
$domain = (empty($domain))? $_SERVER["HTTP_HOST"] : $domain; 
$domain = (substr($domain,0,4) == "www.")? strstr($domain, ".") : $domain;

// Protect database entries and use MD5 encryption 
$strName    = (isset($_POST['name']))? addslashes( $_POST['name'] ) : ''; 
$strUser    = (isset($_POST['user']))? addslashes( $_POST['user'] ) : ''; 
$strKey		= (isset($_POST['code']))? addslashes( $_POST['code'] ) : '';
$strEmail2	= (isset($_POST['email2']))? addslashes( $_POST['email2'] ) : '';


$strDomain  = addslashes( "$domain" ); 
$strPass1   = (isset($_POST['pass1']))? addslashes( $_POST['pass1'] ) : ''; 

//Connect to database using information from above 
$open = mysql_connect($mysql_host, $mysql_user, $mysql_pass); 
$select = mysql_select_db($mysql_db); 

if (!$open || !$select) 
{ 
  echo "Unable to open database, contact your administrator!"; 
} else { 
  echo "<fieldset style=\"width:420px;font-size:12px;\"><legend style=\"font-size:30px;color:blue;width:100px;\">$form_title</legend>"; 
  
 
  if ( isset($_POST['submit']) &&  $_POST['submit'] == 'create account' ){ 
   if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
    $domain_res = mysql_query("SELECT * FROM `hm_domains` WHERE `domainname` = '{$strDomain}' LIMIT 1"); 
      if (!$domain_res) 
      {
        die('Error while selecting data: ' . mysql_error());
       }
      $domain_info = mysql_fetch_array($domain_res, MYSQL_ASSOC);
      


    //Check to see if email account exists, if not process signup 
    $account_res = mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$strDomain' LIMIT 1"); 
    $v1 = mysql_num_rows($account_res); 
        
    If ($v1 >= 1) 
    { 
       echo "A subscriber with this email already exists!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset."; 
       return false;
    } else { 
      if ( !$_POST['pass1'] || !$_POST['pass2'] ) 
      { 
         echo "You did not enter both passwords!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset."; 
      } 
      elseif ( $_POST['pass1'] != $_POST['pass2'] ) 
      { 
         echo "The passwords entered do not match!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset."; 
      } else { 
         $domain_id = $domain_info['domainid'];
         $account_pass = ($encryption == 2)? md5( $strPass1 ) : $strPass1;

         $account_add = mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`,`code`,`email2`) VALUES ('$domain_id','$strUser@$strDomain','$account_pass','$admin_default_activate','$accountisad','$account_max','$encryption','$strKey','$strEmail2')");
       
// Find the accountid for the newly created account based off of domain id and account address
$query = mysql_query("SELECT accountid FROM hm_accounts
WHERE accountdomainid='$domain_id' AND accountaddress='$strUser@$strDomain'") or die(mysql_error());
$col = mysql_fetch_array($query);
$account_info = $col ['accountid'];

// Match folderaccountid with accountid
$folderaccountid = $account_info;
$folderparentid = '-1';
$folderissubscribed = '1';
$foldercurrentuid = '1';

// Build IMAP Folders
  $imapfolders_add = mysql_query("
   INSERT INTO hm_imapfolders (folderaccountid, folderparentid, foldername, folderissubscribed,foldercurrentuid)
      SELECT '$folderaccountid', '$folderparentid', 'INBOX', '$folderissubscribed', '$foldercurrentuid'
   UNION ALL
      SELECT '$folderaccountid', '$folderparentid', 'Sent', '$folderissubscribed', '$foldercurrentuid'
   UNION ALL
      SELECT '$folderaccountid', '$folderparentid', 'Trash', '$folderissubscribed', '$foldercurrentuid'
   UNION ALL
      SELECT '$folderaccountid', '$folderparentid', 'Junk', '$folderissubscribed', '$foldercurrentuid'
      ");
      } 
    } 
    
    if (!$account_add) 
      {
        die('<br><br>Database error, unable to add account. Please contact your administrator!<br> ' . mysql_error());
       }
        
    If ($admin_default_activate == 0) 
   { 
     echo "<div style=\"font-size:14px;color:red;\"><b>Your account has been created but <b>requires activation</b> by administration."; 
      echo "Once your application has been approved, you will receive a confirmation message.</div><br><br>"; 
    } else { 
      echo "<div style=\"font-size:14px;color:red;\"><b>Your account has been created and is ready for use!</b><br>"; 
      echo "<b>Username</b>:<i> $strUser@$strDomain</i><br>"; 
      if ( !empty($serv_webmail_url) ) echo "<b>Webmail URL</b>: <a href=\"$serv_webmail_url\">www.$strDomain/</a></div><br>"; 
      
      
      $subject = "Welcome To $strDomain Email!"; 
      $message = "This is confirmation that your account has been created. You may now login to your account and start using it."; 

      mail("{$_POST['user']}@$strDomain", "$subject", "$message", "From: $admin_email"); //Send welcome message 
    } 
        
    if ($admin_default_activate == 0 && $admin_notify == 1) 
    { 
      $admin_mail_subject = "Account Requires Activation!"; 
      $admin_mail_message = "The email account {$_POST['user']}@$strDomain has been created by {$_POST['name']} and requires administration activation!\r\n\r\nPlease login to the admin control panel to verIfy and activate user account.\r\n\r\n"; 
      mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $admin_email"); 
    } 
    elseif ($admin_default_activate == 1 && $admin_notify == 1) 
    { 
      $admin_mail_subject = "New Account Created!"; 
      $admin_mail_message = "{$_POST['user']}@$strDomain has been created by {$_POST['name']}!"; 
      mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $admin_email"); 
      
    } 
    unset($_SESSION['security_code']);
  } else {
		// Insert your code for showing an error message here
		echo "<div style=\"font-size:13px;color:red;\"><b>Sorry, you have provided an invalid security code <br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset.</b></div>";
   }
 }
}  
   //Email account signup page 
  echo "<form action=\"\" method=\"POST\">
 <table style=\"font-size:14px;color:#535353;\"><tr>
  <td width=\"100\"><b>Full Name:</b></td><td width=\"220\"><input type=\"text\" name=\"name\" size=\"18\"> </td></tr><tr>
      <td><b>E-Mail:</td><td><input type=\"text\" name=\"user\" size=\"18\"><b><font color=red>@".$domain."</font></b> </td></tr><tr>
      <td><b>Password:</td><td><input type=\"password\" name=\"pass1\" size=\"18\"> </td></tr><tr>
      <td><b>Password:</td><td><input type=\"password\" name=\"pass2\" size=\"18\"> (For Confirmation)</td></tr>
	  <td><b><font color=red>Backup Email</font>:</td><td><input type=\"text\" name=\"email2\" size=\"18\"> (To Receive Reset Link)</td></tr>
	  <td><b><font color=red>Secret Word/Code</font>:</td><td><input type=\"password\" name=\"code\" size=\"18\"> (If you forget password)</td></tr>
	  
	  <tr><td>&nbsp;</td><td align=\"left\"><br />";
  echo "<img src=\"CaptchaSecurityImages.php?width=150&height=35&characters=7\" /></td>
		</tr><tr><td><label for=\"security_code\"><b>Security Code: </b></label></td><td><input id=\"security_code\" name=\"security_code\" type=\"text\" /><br /></td>
     </tr><br><br><tr><td colspan=\"2\" align=\"center\"><input type=\"image\" src=\"button.png\" name=\"submit\" value=\"create account\" ></td></tr></table> </fieldset>
   </form>"; 


  ?>

</center></body>


This is a script that get information from a form and insert it into a database (MySQL).
The problem with this script is that it works on Google Chrome but it doesn't work on Firefox or Internet Explorer.

What happen after user click register button :
Form gets wipe and page looks like it refresh.

What's suppose to happen :
It's supposed to echo out some text and a link that will take them back 1 page with history.go(-1) but none of that showed up on the screen. It just flash and the page is reset.

I'm not sure why it's working on Google Chrome but not firefox or internet explorer

Is This A Good Question/Topic? 0
  • +

Replies To: Code not working for Firefox or Internet Explorer?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3389
  • View blog
  • Posts: 9,577
  • Joined: 08-June 10

Re: Code not working for Firefox or Internet Explorer?

Posted 03 July 2013 - 11:50 PM

#1, your session does not start (that would be one of the suppressed error notices)

#2, the mysql extension is deprecated (see signature)

#3, addslashes() must not be used for escaping SQL values (there is a reason for the *_real_escape_string() functions)

#4, donít use tables for layout

#5, donít quote variables like that: "$var", PHP does that automatically and $_POST/$_GET always get you a string anyways

#6, line #26 will throw an error if the connect failed

#7, if you need to escape quotes inside a string, chances are that you should change the outer quotes. (there are also neat string definitions like HEREDOC, which let you use both (single and double) quotes without escaping)
Was This Post Helpful? 0
  • +
  • -

#3 Mause  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-July 13

Re: Code not working for Firefox or Internet Explorer?

Posted 04 July 2013 - 12:07 AM

Thanks for showing me all or most of the errors but I'm still confused as to why it works 100% on Google Chrome but when it's on Firefox or Internet Explorer it doesn't do anything.

This post has been edited by Dormilich: 04 July 2013 - 12:39 AM

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3389
  • View blog
  • Posts: 9,577
  • Joined: 08-June 10

Re: Code not working for Firefox or Internet Explorer?

Posted 04 July 2013 - 12:38 AM

first you should also enable error notices.
Was This Post Helpful? 0
  • +
  • -

#5 Leticia Wren  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 18
  • Joined: 05-July 13

Re: Code not working for Firefox or Internet Explorer?

Posted 06 July 2013 - 03:20 AM

yes i do agree with Dormilich but i must say that PHP and MySQL are still good and mostly used.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1