Jump to content


Photo

jQuery Modal doesn't show up


  • Please log in to reply
37 replies to this topic

#21 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 29 September 2013 - 08:57 AM

READ THE NEXT POST

 

The Javascript for "email available check" is disabled. Now the popup shows again, with the information that was put in the form.

 

But the problem still is that the user is not created. I think the form page and form_process.php not working together.

 

This code:

if(isset($_POST['submit']))
{
	$strName    = addslashes( $_POST['name'] );
	$strUser    = addslashes( $_POST['user'] );
	$strDomain  = addslashes( $_POST['domain'] );
	$strPass1   = addslashes( $_POST['pass1'] );
	$strMD5Pass = md5( $strPass1 );
	$kod    = addslashes( $_POST['kod'] );

is in both the .php files... I really dont know why its not working.

 

BUT! "create.php" handles both the database INSERT and the form, so there is some conflict between the files..


Edited by Hampe, 29 September 2013 - 08:58 AM.


#22 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 29 September 2013 - 09:00 AM

Lets start from the beginning. We have 1 file (create.php) that works perfect. Can we (you or me.. I dont know) make the Modal Popup work in that file, or there must be a "form_process.php" ?



#23 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 29 September 2013 - 10:56 AM

If you want the modal to appear without the page reloading when the submit button is pressed you'll need to use ajax. PHP is ran on the server. Javascript is ran in the browser  which is executed way after PHP has finished processing the script. You cannot send data to and from the server without the page reloading, unless you use ajax.

 

If you implement my ajax method (just the javascript code) in post#13 to your code in post #6 (which I assume is create.php. and give the form an id of mailSetupForm)). and set the ajax request to create.php it should run as you expect, but the page will duplicate!. You only want the modal returned from the ajax request. This is happening because you process the form data from lines ~160 to ~280. You output the modal on line ~298. Any html/text outputted before that line will be sent back to the ajax request and this why the page duplicates.

 

Moving the PHP code on lines 160 - 280 in create.php to form_process.php will prevent this from happening,as that file is only returning the html for the modal when the user has been added to the database not the entire page of create.php!

 

form_process.php can be named to any thing just like any other php file you create. You just reference that file in the ajax request, like you would with any file you link to.

 

Hope I have made it clearer now what I'm trying to get your to implement. if you're not happy with this then please say.


Edited by Ch0cu3r, 29 September 2013 - 10:58 AM.


#24 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 30 September 2013 - 01:54 AM

Good morning!

 

I start this day and thread by say thank you for all the help! I really appreciate it.

 

I did what you told me to do, but it just wont create the user. As before, I get the Popup with the information but nothing more then that. I have test with all-in-one code in "create.php", and with separate files, where line ~160 - ~280 were moved to "form_process.php". And I have been testing with 2-3 other things too...

 

There is some sort of conflict in the code, I just dont know what it is!

 

I´ll go nuts soon!!  :-\


Edited by Hampe, 30 September 2013 - 01:58 AM.


#25 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 30 September 2013 - 03:32 AM

Okay. Post create.php and form_process.php here I will check it out



#26 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 30 September 2013 - 06:33 AM

create.php 

			<?php 
			$a = mt_rand(10000000,99999999);
			?>

<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))
header('Location: http://www.Website.se/mobil/mail.php');
?>

<?php

if ($_REQUEST['id'] == "faq") {
		include('submeny/faq.php');
	}
else {

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>

	
	<link rel="icon" type="image/png" href="http://www.Website.se/img/favicon.ico">

	<title>Website.se</title>

	<style type="text/css" media="all">
		@import "css/global.css";
		@import "css/toprightheader.css";
		@import "css/anslutning.css";
		@import "css/tooltip.css";
		@import "popup/css/styles.css";
	</style>


<!--jQuery-->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<script src="http://malsup.github.com/min/jquery.form.min.js"></script> <!-- using AjaxForm JQuery plugin-->
	<script src="popup/js/jquery.reveal.js"></script>
	
	<script type="text/javascript">
		$(document).ready(function() {

			var options = { 
			url: 		"form_process.php", // where to submit form to
		        type: 		"post",             // submit method
		        dateType:	"html",             // returned dataType
		        success:	showResponse        // function to call on successful form submittion
		    }; 
 
		    // bind form using 'ajaxForm' 
		    $('#mailSetupForm').ajaxForm(options);


		});

		function showResponse(responseText) {
	        console.log('success');
	        $('#wrapper').prepend(responseText); // prepend the modal to #wrapper dib

                        // display modal
		   	$('#modal').reveal({ // The item which will be opened with reveal
			  	animation: 'fade',                   // fade, fadeAndPop, none
				animationspeed: 600,                       // how fast animtions are
				closeonbackgroundclick: false,              // if you click background will modal close?
				dismissmodalclass: 'close'    // the class of a button or element that will close an open modal
			});

		}
	</script>


</head>

<body>
<div id="wrapper">
	<div id="header">
		<img src="img/logo.png">
		<!--<h1><span class="black">Web</span><span class="orange">Site</span><span class="black">.se</span></h1>-->
		<!--<h2>Your Slogan</h2>-->
	</div>
	<div id="anslutning">
		<div id="anslutningnavi">
			<ul>
				<!--<li><a href="#">Logga in - Kontrollpanel</a></li>-->
					<?php
			
					$portstatus = $_SERVER['SERVER_PORT'];
					if ($portstatus==80) {
					echo'<li><a href="https://www.Website.se' . $_SERVER['REQUEST_URI'] . '">Byt till Säker Anslutning (HTTPS)</a></li>';
			
					} else {
			
					echo'<li><a href="http://www.Website.se' . $_SERVER['REQUEST_URI'] . '">Byt till Osäker Anslutning (HTTP)</a></li>';
			
					}
			
					?>
			</ul>
		</div>
	</div>
	<div id="rightheader">
		<div id="rightheadernavi">
			<ul>
				<!--<li><a href="#">Logga in - Kontrollpanel</a></li>-->
				<li><a href="../webmail" target="_blank"><img src="img/email-logo.png" width="20" height="20">Webmail</a></li>
			</ul>
		</div>
	</div>
	<div id="navi">
		<ul>
			<li><a href="/">Start</a></li>
			<li class="active"><a href="?p=mail">Mail</a></li>
			<li><a href="?p=driftstatus">Driftstatus</a></li>
			<li><a href="?p=kontakt">Kontakta oss</a></li>
		</ul>
	</div>
	<div id="subnavi">
		<ul>
			<li><a href="?p=mail&id=faq">FAQ</a></li>
		</ul>
	</div>
	<div id="main">
		<div class="ic"></div>
		<div id="content">
			<h1><span>Skapa Email-konto</span></h1>

			
			<div id="content">
			
			<!-- <h2>Funktionen är avstängd tills vidare</h2> -->
			
		
<!--		
<script type="text/javascript" src="js/jquery.js"></script>
<script>

$(document).ready(function(){
$('#user').keyup(user_check);
$('#domain').change(user_check);
});
	
function user_check(){	
var user = $('#user').val();
var domain = $('#domain').val();
var email = user + '@' + domain;
$('#output').text(email); 
if(email === "" || user.length < 4){
$('#email').css('border', '3px #CCC solid');
$('#tick').hide();
}else{

jQuery.ajax({
   type: "POST",
   url: "mail/check/check.php",
   data: 'email='+ email,	
   cache: false,
   success: function(response){
if(response == 1){
	$('#email').css('border', '3px #C33 solid');	
	$('#tick').hide();
	$('#cross').fadeIn();
	}else{
	$('#email').css('border', '3px #090 solid');
	$('#cross').hide();
	$('#tick').fadeIn();
}

}
});
}



}

</script>

-->

<style>

#tick{display:none}
#cross{display:none}
	

</style>

<?php

//MySQL Information:
$mysql_host = "localhost"; //Host Name
$mysql_user = "user"; //Username
$mysql_pass = "password"; //Password
$mysql_db = "database"; //Database

//General Configuration:
$account_max = "10"; //Maximum size per account (MB)

$admin_notify = 0; //1 = yes & 0 = no
$admin_email = "email@Website.se"; //Administrators email to send notifications)
$admin_default_activate = 1; //1 = yes & 0 = no -> If no, the administrator has to authorise the account
$encryption = 2; //Password encryption level

//DO NOT EDIT BELOW!//

// Protect the Database and MD5 the password.
$strName    = addslashes( $_POST['name'] );
$strUser    = addslashes( $_POST['user'] );
$strDomain  = addslashes( $_POST['domain'] );
$strPass1   = addslashes( $_POST['pass1'] );
$strMD5Pass = md5( $strPass1 );
$kod    = addslashes( $_POST['kod'] );

error_reporting(E_ALL ^ E_NOTICE);
//Next two lines 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 'Databasfel! Felkod: "DB_NoConn"'; 
}
ELSE
{
    //Decide On What Path To Take
    SWITCH ($_GET['atgard'])
    {
    CASE "skapa":
        //#### PAGE IF FORM FILLED OUT ####//
        $q=mysql_query("SELECT * FROM `hm_domains` WHERE `domainid` = '{$strDomain}' LIMIT 1"); //Load Domain Into memory (internal use)
        WHILE ($v=mysql_fetch_array($q)) 
        { 
            $temp_domain = $v['1']; 
        
        } //Apply information

        $q2=mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$temp_domain' LIMIT 1"); //Check if account exists
        $v2=mysql_num_rows($q2); //Gets number of accounts that exist with that profile (should be less than or equal to one)
        
        IF ($v2 == 1) 
        { 
            echo "<span style=\"color:red\">Email-adressen finns redan! <a href=\"javascript:history.go(-1)\">Tillbaka</a><br /></span>"; 
        }
        ELSE
        {
            IF (!$_POST['pass1'] || !$_POST['pass2']) 
            { 
                echo "<span style=\"color:red\">Du fyllde inte i båda lösenorden! <a href=\"javascript:history.go(-1)\">Tillbaka</a><br /></span>"; 
            }
            ELSEIF ($_POST['pass1'] <> $_POST['pass2']) 
            { 
                echo "<span style=\"color:red\">Lösenorden matchade inte varandra! <a href=\"javascript:history.go(-1)\">Tillbaka</a><br /></span>"; 
            }
            ELSE
            {
                $q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`,`kod`) VALUES ('1','$strUser@Website.se','$strMD5Pass','$admin_default_activate','0','$account_max','$encryption','$kod')") or die(mysql_error());
            }
        }
        
        IF ($q3)
        {
            IF ($admin_default_activate == 0)
            {
                echo "<span style=\"color:green\">Ditt konto är skapat, <b>men kräver att administratören aktiverar det.</b> Du får snart en bekräftelse om detta.</span>";
            }
            ELSE
            {
                echo "
				
				<div id=\"modal\">
						<div id=\"heading\">
						Ditt mailkonto är aktiverat!
						</div>

						<div id=\"boxcontent\">
						<p><b>Uppgifter:</b><br>Email: $strUser@Website.se<br />Lösenord: (Dolt av säkerhetsskäl)</p>

						<a href=\"#\" class=\"button red close\"><img src=\"popup/images/cross.png\">Stäng</a>
						</div>
					</div>
				
				";
                $subject = "<span style=\"color:green\">Välkommen till Website!</span>";
                $message = "<span style=\"color:green\">Detta är en bekräftelse på att ditt email-konto är skapat.</span>";

                //mail("$strUser@Website.se", $subject, $message); //Send welcome message
            }
        }
        ELSE
        {
            //echo "<span style=\"color:red\">Database fel, kunde inte skapa email-kontot. Kontakta administratören!</span>";
        }

        IF ($admin_default_activate == 0 && $admin_notify == 0)
        {
            $admin_mail_subject = "Account Requires Activation!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']} and needs to be activated!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
        ELSEIF ($admin_default_activate == 1 && $admin_notify == 1)
        {
            $admin_mail_subject = "New Account Created!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
         ELSEIF ($admin_default_activate == 0 && $admin_notify == 1)
        {
            $admin_mail_subject = "New Account Created!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
        break;
    
    DEFAULT:
    }


//#### KOD SOM VISAS OM FÄLTEN INTE ÄR IFYLLDA ####//
echo "
";
}
?>


<span style="color:red">*</span> = Required fields must be filled in
<form action="?p=mail&atgard=skapa" method="POST" id="mailSetupForm">
 <table style="font-size:14px;color:#535353;">
   <tr>
  <td><b>Your name:</b></td><td><input type="text" name="name" size="10"> </td></tr><tr><td></td></tr>
      <tr><td><b>E-Mail: <span style="color:red">*</span></b></td><td><input type="text" name="user" id="user" size="10"><b> @ <select name="domain" id="domain">
			<option id="1" value="Website.se">Website.se</option>
	  </select></b> <!--<label id="output"></label> <img id="tick" src="mail/check/tick.png" width="16" height="16" title="Adressen är ledig"/><img id="cross" src=\"mail/check/cross.png" width="16" height="16" title="Adressen är upptagen"/>--> </td></tr>
      <tr><td><b>Password:: <span style="color:red">*</span></b></td><td><input type="password" name="pass1" size="10"> </td></tr>
      <tr><td><b>Password again: <span style="color:red">*</span></b></td><td><input type="password" name="pass2" size="10"> (Confirmation)</td></tr>
	  <tr><td><b>Code:</b></td><td><input type="text" name="kod" size="8" value="$a" readonly="readonly"> Save this code! Used when requestar new password</td></tr>";

	  <tr><td> <div align="left"><input type="submit" name="submit" id="button" value="Skapa"></div></td></tr></table> </fieldset>
</form>



		</div>
		
		</div>
	
		<div id="news">
			<h1>Nyheter</h1>
			
				<?php include('include/nyheter-box.php'); ?>
			
		</div>
	</div>
	<div id="footer">
		<p>© Copyright 2013 Website.se. Alla Rättigheter Reserverade.</p>
	</div>
	<div class="cleaner"></div>
</div>
</body>
</html>






<?php
}
?>

form_process.php

<?php
//DO NOT EDIT BELOW!//

// Protect the Database and MD5 the password.

if(isset($_POST['submit']))
{
	$strName    = addslashes( $_POST['name'] );
	$strUser    = addslashes( $_POST['user'] );
	$strDomain  = addslashes( $_POST['domain'] );
	$strPass1   = addslashes( $_POST['pass1'] );
	$strMD5Pass = md5( $strPass1 );
	$kod    = addslashes( $_POST['kod'] );

//printf('<pre>%s</pre>', print_r($_POST, true));

// only return the modal. Do not return any other html
echo <<<HTML
<div id="modal">
		<div id="heading">
			Your mailaccount is activated!
		</div>

		<div id="boxcontent">
		<p><b>Account Details:</b><br>Email: $strUser@Website.se<br />Password: $strPass1</p>

		<a href="#" class="button red close"><img src="popup/images/cross.png">Close Window</a>
	</div>
</div>
HTML;
// DO NOT MODIFY LINE ABOVE

}
?>

I kindly ask you, please keep the code intact. Dont remove 50% of the code, it's a pain in the a** to build it up again with the new functions..  :sweat:


Edited by Hampe, 30 September 2013 - 06:33 AM.


#27 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 30 September 2013 - 08:24 AM

That is because you still have the form processing code in create.php. The form processing code in I am referring to are lines 192 to line 329. Cut and paste those lines into form_process.php replacing my example code. 

 

Once you have moved the code delete the following lines from form_process.php

    //Decide On What Path To Take
    SWITCH ($_GET['atgard'])
    {
    CASE "skapa":

and

        break;
    
    DEFAULT:
    }

 

Those lines are not needed.


Edited by Ch0cu3r, 30 September 2013 - 08:35 AM.


#28 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 30 September 2013 - 01:37 PM

Okey, the beta test is started for real now. The popup box is acting wierd, but I will test a few things first.

 

I will be back in 10-30 min  :)



#29 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 30 September 2013 - 05:22 PM

Okey, I got the code to work after a few  :facewall:    in the keyboard. But if I try to create an account that already exists, the error doesn't show up in the popupbox as I want to. Instead this text pops up on the page:

Duplicate entry 'test@mywebsite.se' for key 'accountaddress

The strange thing is that I can't find that textrow in the code. Is it possible that the error message comes from the database? 



#30 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 01 October 2013 - 04:32 AM

Ok. Umm,Have you modified form_process.php? As I have tested the code but I cant seem to reproduce that error. I get Email-adressen finns redan! if there is duplicate email address found

 

I have edited form_process.php to output debug information. When the form is submitted a red box should appear post the debug info here

<pre style="border:2px solid red;">
<?php

//MySQL Information:
$mysql_host = "localhost"; //Host Name
$mysql_user = "root"; //Username
$mysql_pass = "root"; //Password
$mysql_db = "test"; //Database

//General Configuration:
$account_max = "10"; //Maximum size per account (MB)

$admin_notify = 0; //1 = yes & 0 = no
$admin_email = "email@Website.se"; //Administrators email to send notifications)
$admin_default_activate = 1; //1 = yes & 0 = no -> If no, the administrator has to authorise the account
$encryption = 2; //Password encryption level

//DO NOT EDIT BELOW!//

echo "DEBUG: Posted Info\n\nPOST " . print_r($_POST, true);

// Protect the Database and MD5 the password.
$strName    = addslashes( $_POST['name'] );
$strUser    = addslashes( $_POST['user'] );
$strDomain  = addslashes( $_POST['domain'] );
$strPass1   = addslashes( $_POST['pass1'] );
$strMD5Pass = md5( $strPass1 );
$kod    = addslashes( $_POST['kod'] );

error_reporting(E_ALL ^ E_NOTICE);
//Next two lines connect to database using information from above.
$open = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$select = mysql_select_db($mysql_db);
$open = $select = true;
IF (!$open || !$select) 
{ 
    echo 'Databasfel! Felkod: "DB_NoConn"'; 
}
ELSE
{
        echo "DEBUG: Querying hm_domains for domain id\n\n"; // DEBUG
        //#### PAGE IF FORM FILLED OUT ####//
        $q=mysql_query("SELECT * FROM `hm_domains` WHERE `domainid` = '{$strDomain}' LIMIT 1"); //Load Domain Into memory (internal use)
        WHILE ($v=mysql_fetch_array($q)) 
        { 
            $temp_domain = $v['1']; 

            echo "RESULT: `domainid` = '{$strDomain}' Found $temp_domain\n\n";
        
        } //Apply information

        if(!isset($temp_domain) echo "DEBUG: $strDomain (\$strDomain) not found in hm_domains\n\n"; // DEBUG
        echo "DEBUG: Querying hm_accounts to see if email address exists ({$strUser}@$temp_domain)\n\n";

        $q2=mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$temp_domain' LIMIT 1"); //Check if account exists
        $v2=mysql_num_rows($q2); //Gets number of accounts that exist with that profile (should be less than or equal to one)*/
        
        IF ($v2 == 1) 
        {
            echo "DEBUG: email address exists! ({$strUser}@$temp_domain)\n\n"; //DEBUG
            echo "<span style=\"color:red\">Email-adressen finns redan! <a href=\"javascript:history.go(-1)\">Tillbaka</a><br /></span>"; 
        }
        ELSE
        {
            echo "DEBUG: email address ok!\n\n"; // DEBUG
            IF (!$_POST['pass1'] || !$_POST['pass2']) 
            { 
                echo "<span style=\"color:red\">Du fyllde inte i båda lösenorden! <a href=\"javascript:history.go(-1)\">Tillbaka</a><br /></span>"; 
            }
            ELSEIF ($_POST['pass1'] <> $_POST['pass2']) 
            { 
                echo "<span style=\"color:red\">Lösenorden matchade inte varandra! <a href=\"javascript:history.go(-1)\">Tillbaka</a><br /></span>"; 
            }
            ELSE
            {
                echo "DEBUG: Email fine add account to hm_accounts\n\n"; // DEBUG
                $q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`,`kod`) 
                                                    VALUES ('1','$strUser@Website.se','$strMD5Pass','$admin_default_activate','0','$account_max','$encryption','$kod')") or die("DEBUG:\n\tMYSQL Error: " . mysql_error());
            }
        }
        
        IF ($q3)
        {
            echo "DEBUG: Account created!\n\n"; // DEBUG
            IF ($admin_default_activate == 0)
            {
                echo "<span style=\"color:green\">Ditt konto är skapat, <b>men kräver att administratören aktiverar det.</b> Du får snart en bekräftelse om detta.</span>";
            }
            ELSE
            {
                echo "DEBUG: Display modal\n\n"; // DEBUG
                echo "
                
                <div id=\"modal\">
                    <div id=\"heading\">
                        Ditt mailkonto är aktiverat!
                    </div>

                    <div id=\"boxcontent\">
                        <p>
                            <b>Uppgifter:</b><br />
                            Email: $strUser@Website.se<br />
                            Lösenord: (Dolt av säkerhetsskäl)
                        </p>

                        <a href=\"#\" class=\"button red close\"><img src=\"popup/images/cross.png\">Stäng</a>
                    </div>
                </div>
                
                ";
                
                $subject = "<span style=\"color:green\">Välkommen till Website!</span>";
                $message = "<span style=\"color:green\">Detta är en bekräftelse på att ditt email-konto är skapat.</span>";

                //mail("$strUser@Website.se", $subject, $message); //Send welcome message
            }
        }
        ELSE
        {
            //echo "<span style=\"color:red\">Database fel, kunde inte skapa email-kontot. Kontakta administratören!</span>";
        }

        IF ($admin_default_activate == 0 && $admin_notify == 0)
        {
            $admin_mail_subject = "Account Requires Activation!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']} and needs to be activated!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
        ELSEIF ($admin_default_activate == 1 && $admin_notify == 1)
        {
            $admin_mail_subject = "New Account Created!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }
         ELSEIF ($admin_default_activate == 0 && $admin_notify == 1)
        {
            $admin_mail_subject = "New Account Created!";
            $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
            mail($admin_email, $admin_mail_subject, $admin_mail_message);
        }



//#### KOD SOM VISAS OM FÄLTEN INTE ÄR IFYLLDA ####//
echo "
";
}
?></pre>


#31 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 01 October 2013 - 06:12 AM

I will take a look at it when I'm home again.

 

We keep in touch!



#32 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 02 October 2013 - 08:46 AM

Hi again. Sorry for the waiting..

 

I fixed the problem, and another one that I found at the same time  :tease-01:

 

I thought about one more thing... When I have created the account and press the "Close"-button, the info is still in the form (as it should be..). But I want to delete the information by automatic.

A simple "Javascript Reload" doesn't do the job because you get the question if you really want to reload the page. And dont even think about: "javascript: window.history.go(-1)"..  ;D

 

 

I thought more about maybe "session destroy".. Which is the best option so the user cant just go back 1 page and still see the information in the form?


Edited by Hampe, 02 October 2013 - 08:54 AM.


#33 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 02 October 2013 - 08:58 AM

Does adding

$('#mailSetupForm')[0].reset();

after $('#wrapper').prepend(responseText); within the showResponse() function. Clear the form?

Glad you have got it working now.  ;D


Edited by Ch0cu3r, 02 October 2013 - 09:04 AM.


#34 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 02 October 2013 - 09:18 AM

Well, it does clear the form, but I just want it to be cleared if the account is successfully created.

 

I also use the Popupbox for the error messeges, but it should now clear the form if an error messege pop up 



#35 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 02 October 2013 - 09:27 AM

By clear do you mean remove the actual form from the page, or clear the values entered into the form fields?


Edited by Ch0cu3r, 02 October 2013 - 09:28 AM.


#36 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 02 October 2013 - 09:29 AM

Clear the form, but only when the account is successfully created, and not when it's an error message



#37 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 02 October 2013 - 09:48 AM

How do you display the error message? The error message coming from form_process.php? What is popupbox?

 

Basically what you need to do is check what is being sent back to create.php and then deciding what to do, whether to display modal, or the popupbox. But I dont know how you're implementing the popupbox so I cant tell you.



#38 Hampe

Hampe

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationSweden

Posted 02 October 2013 - 09:57 AM

The error messages are shown on the same way like when a account is created, via "Modal"

echo <<<HTML
<div id="modal">
		<div id="heading">
			Error!
		</div>

		<div id="boxcontent">
		<p>You did not fill in both passwords</p>

		<a href="#" class="button red close"><img src="../popup/images/cross.png">Close</a>
	</div>
</div>
HTML;





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com