PHP, Java, JavaScript, XML, XHTML, HTML, CSS, ASP, Delphi, Assembly, LaTeX, C, UML, Flash, Perl, SQL, Python, Zope, Pascal, WML. Se conhece mais de 3 siglas referidas, este é o forum para si.
Moderadores: Administradores, Moderadores
por [PT]CableGuy » Sexta Fev 23, 2007 12:54
Boas ppl:
Preciso de ajuda para centralizar o "output" deste ficheiro php:
- Código: Seleccionar todos
<?php
//MySQL Information:
$mysql_host = "hostname"; //Host Name
$mysql_user = "username"; //Username
$mysql_pass = "password"; //Password
$mysql_db = "database"; //Database
//General Configuration:
$form_title = "Criar Registro"; //Name for this form
$account_max = "10000000"; //Maximum size per account (1000000 = 1MB -> Do not uses spaces or commas!)
$admin_notify = 1; //1 = yes & 0 = no
$admin_email = "email"; //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 );
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 "Unable to open database, contact your administrator!";
}
ELSE
{
echo "<font size=\"+2\">$form_title</font><br><br>"; //Display form title from above
//Decide On What Path To Take
SWITCH ($_GET['mode'])
{
CASE "do":
//#### 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 "A user with this username already exists! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSE
{
IF (!$_POST['pass1'] || !$_POST['pass2'])
{
echo "You did not enter both passwords! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSEIF ($_POST['pass1'] <> $_POST['pass2'])
{
echo "Your passwords do not match! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSE
{
$q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`) VALUES ('$strDomain','$strUser@$temp_domain','$strMD5Pass','$admin_default_activate','0','$account_max','$encryption')") or die(mysql_error());
}
}
IF ($q3)
{
IF ($admin_default_activate == 0)
{
echo "Your account has been created <b>however requires administrator activation.</b> You should receive a message soon regarding this.";
}
ELSE
{
echo "Your account has been created and is ready for use!<br><br>Username: $strUser@$temp_domain<br><br>Webmail: <a href=\"$serv_webmail/webmail\">http://$temp_domain/webmail</a><br>POP3: $temp_domain<br>IMAP: $temp_domain<br>SMTP: $temp_domain<br>";
$subject = "Welcome To MYWEBSITE!";
$message = "This is confirmation that your account has been created.";
mail("{$_POST['user']}@$temp_domain", $subject, $message); //Send welcome message
}
}
ELSE
{
echo "Database error, unable to add account. Please contact your administrator!";
}
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:
}
}
//#### MAIN PAGE IF FORM NOT FILLED OUT ####//
echo "
<form action=\"?mode=do\" method=\"POST\">
Nome Completo: <input type=\"text\" name=\"name\" size=\"21\"><br>
E-Mail: <input type=\"text\" name=\"user\" size=\"21\"> @ <select name=\"domain\">
";
$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains
{
echo "<option value=\"{$v2['0']}\">{$v2['1']}</option>";
}
echo "
</select><br>
Password: <input type=\"password\" name=\"pass1\" size=\"21\"><br>
Password: <input type=\"password\" name=\"pass2\" size=\"21\"> (confirmação)<br><br>
<input type=\"submit\" value=\"Criar conta\">
</form>
";
?>
A imagem que aparece é (mais ou menos) esta, mas infelizmente está alinhada à esquerda.
Alguém me ajuda a centralizar o output deste ficheiro php ?
Editado pela última vez por
[PT]CableGuy em Sexta Fev 23, 2007 16:02, num total de 1 vez.
-
[PT]CableGuy
- Gurus

-
- Mensagens: 1845
- Registado: Domingo Mai 30, 2004 16:26
por CR9 » Sexta Fev 23, 2007 13:15
- Código: Seleccionar todos
<?php
//MySQL Information:
$mysql_host = "hostname"; //Host Name
$mysql_user = "username"; //Username
$mysql_pass = "password"; //Password
$mysql_db = "database"; //Database
//General Configuration:
$form_title = "Criar Registro"; //Name for this form
$account_max = "10000000"; //Maximum size per account (1000000 = 1MB -> Do not uses spaces or commas!)
$admin_notify = 1; //1 = yes & 0 = no
$admin_email = "email"; //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 );
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 "Unable to open database, contact your administrator!";
}
ELSE
{
echo "<font size=\"+2\">$form_title</font><br><br>"; //Display form title from above
//Decide On What Path To Take
SWITCH ($_GET['mode'])
{
CASE "do":
//#### 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 "A user with this username already exists! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSE
{
IF (!$_POST['pass1'] || !$_POST['pass2'])
{
echo "You did not enter both passwords! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSEIF ($_POST['pass1'] <> $_POST['pass2'])
{
echo "Your passwords do not match! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSE
{
$q3=mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`) VALUES ('$strDomain','$strUser@$temp_domain','$strMD5Pass','$admin_default_activate','0','$account_max','$encryption')") or die(mysql_error());
}
}
IF ($q3)
{
IF ($admin_default_activate == 0)
{
echo "Your account has been created <b>however requires administrator activation.</b> You should receive a message soon regarding this.";
}
ELSE
{
echo "Your account has been created and is ready for use!<br><br>Username: $strUser@$temp_domain<br><br>Webmail: <a href=\"$serv_webmail/webmail\">http://$temp_domain/webmail</a><br>POP3: $temp_domain<br>IMAP: $temp_domain<br>SMTP: $temp_domain<br>";
$subject = "Welcome To MYWEBSITE!";
$message = "This is confirmation that your account has been created.";
mail("{$_POST['user']}@$temp_domain", $subject, $message); //Send welcome message
}
}
ELSE
{
echo "Database error, unable to add account. Please contact your administrator!";
}
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:
}
}
//#### MAIN PAGE IF FORM NOT FILLED OUT ####//
echo "
<form action=\"?mode=do\" method=\"POST\">
<div align="left">Nome Completo: <div align="left"><input type=\"text\" name=\"name\" size=\"21\"><br>
<div align="left">E-Mail: <div align="left"><input type=\"text\" name=\"user\" size=\"21\"> @ <select name=\"domain\">
";
$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains
{
echo "<option value=\"{$v2['0']}\">{$v2['1']}</option>";
}
echo "
</select><br>
<div align="left">Password: <div align="left"><input type=\"password\" name=\"pass1\" size=\"21\"><br>
<div align="left">Password: <div align="left"><input type=\"password\" name=\"pass2\" size=\"21\"> (confirmação)<br><br>
<input type=\"submit\" value=\"Criar conta\">
</form>
";
?>
Assim?
Não sabe assinar
-
CR9
- Membro Vitalício

-
- Mensagens: 2393
- Registado: Sábado Ago 27, 2005 15:48
por [PT]CableGuy » Sexta Fev 23, 2007 13:53
Thanks
CR9 !!!

Infelizmente esse ficheiro gera uma página em branco.
PS: <div align="left"> ??? Não seria
<div align="center"> ??

-
[PT]CableGuy
- Gurus

-
- Mensagens: 1845
- Registado: Domingo Mai 30, 2004 16:26
por [PT]CableGuy » Sexta Fev 23, 2007 14:28
Olá novamente:
O "melhor" que consegui foi criando uma tabela:
- Código: Seleccionar todos
//#### MAIN PAGE IF FORM NOT FILLED OUT ####//
echo "
<form action=\"?mode=do\" method=\"POST\">
<table style='border:1px solid #000000;'>
<tr>
<td align='left'>
Nome : <input type=\"text\" name=\"name\" size=\"21\"><br>
E-Mail: <input type=\"text\" name=\"user\" size=\"21\"> @ <select name=\"domain\">
";
$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains
{
echo "<option value=\"{$v2['0']}\">{$v2['1']}</option>";
}
echo "
</select><br>
Password: <input type=\"password\" name=\"pass1\" size=\"21\"><br>
Password: <input type=\"password\" name=\"pass2\" size=\"21\"> (confirmação)<br><br>
<input type=\"submit\" value=\"Criar conta\">
</td>
</tr>
</table>
</form>
";
?>
Agora aparece assim:
Mas infelizmente essa tabela continua do lado esquerdo da página e eu pretendia centralizar TUDO.
-
[PT]CableGuy
- Gurus

-
- Mensagens: 1845
- Registado: Domingo Mai 30, 2004 16:26
por alfatek » Sexta Fev 23, 2007 15:07
antes da tabela:
<div style="margin-left:auto; margin-right:auto; text-align:center;">
depois da tabela:
</div>
-
alfatek
- Administrador

-
- Mensagens: 3257
- Registado: Sábado Abr 06, 2002 18:28
- Localização: Coimbra
-
por CR9 » Sexta Fev 23, 2007 15:08
[PT]CableGuy Escreveu:PS: <div align="left"> ??? Não seria
<div align="center"> ??

Não, dá o mesmo.

(Por o menos a mim)
Não sabe assinar
-
CR9
- Membro Vitalício

-
- Mensagens: 2393
- Registado: Sábado Ago 27, 2005 15:48
por [PT]CableGuy » Sexta Fev 23, 2007 15:17
alfatek Escreveu:antes da tabela:
<div style="margin-left:auto; margin-right:auto; text-align:center;">
depois da tabela:
</div>
O código ficou o seguinte, mas
infelizmente continua a aparecer uma página em branco:
- Código: Seleccionar todos
//#### MAIN PAGE IF FORM NOT FILLED OUT ####//
echo "
<form action="?mode=do" method="POST">
<div style="margin-left:auto; margin-right:auto; text-align:center;">
<table style='border:1px solid #000000;'>
<tr>
<td align='left'>
Nome : <input type="text" name="name" size="21"><br>
E-Mail: <input type="text" name="user" size="21"> @ <select name="domain">
";
$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains
{
echo "<option value="{$v2['0']}">{$v2['1']}</option>";
}
echo "
</select><br>
Password: <input type="password" name="pass1" size="21"><br>
Password: <input type="password" name="pass2" size="21"> (confirmação)<br><br>
<input type="submit" value="Criar conta">
</td>
</tr>
</table>
</div>
</form>
";
?>
PS: Tentei colocar antes da form, depois da tabela, sem tabela...ARGHHH !!!
(é impressionante mas às vezes coisas simples são as mais complicadas)
-
[PT]CableGuy
- Gurus

-
- Mensagens: 1845
- Registado: Domingo Mai 30, 2004 16:26
por [PT]CableGuy » Sexta Fev 23, 2007 16:01
Bem...tava dificil.
- Código: Seleccionar todos
//#### MAIN PAGE IF FORM NOT FILLED OUT ####//
echo "
<div align=\"center\"><form action=\"?mode=do\" method=\"POST\">
<table style='border:1px solid #000000;'>
<tr>
<td align='left'>
Nome : <input type=\"text\" name=\"name\" size=\"21\"><br>
E-Mail: <input type=\"text\" name=\"user\" size=\"21\"> @ <select name=\"domain\">
";
$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains
{
echo "<option value=\"{$v2['0']}\">{$v2['1']}</option>";
}
echo "
</select><br>
Password: <input type=\"password\" name=\"pass1\" size=\"21\"><br>
Password: <input type=\"password\" name=\"pass2\" size=\"21\"> (confirmação)<br><br>
<input type=\"submit\" value=\"Criar conta\">
</td>
</tr>
</table>
</form></div>
";
?>
O "segredo" era "alinhar" a form.
<div align=\"center\"><form action=\"?mode=do\" method=\"POST\">
Obrigado
CR9 e
alfatek pelo contributo.

-
[PT]CableGuy
- Gurus

-
- Mensagens: 1845
- Registado: Domingo Mai 30, 2004 16:26
por alfatek » Domingo Fev 25, 2007 1:49
hum.... devia dar tanto para centrares antes como depois do form. Mas faz mais sentido meter o div antes do form. A página em branco que aparecia, não seria parse_errors do PHP? verifica se tens o PHP a mostrar os erros (por default acho que não está)
-
alfatek
- Administrador

-
- Mensagens: 3257
- Registado: Sábado Abr 06, 2002 18:28
- Localização: Coimbra
-
por sowmika » Sexta Jun 25, 2010 13:12
Hi,very nice post,really this is knowledgeable code ,really good.also one more good chance for your PHP site ,that is domain name and hosting site ,you can approach this
http://www.thewebpole.com/ site ,here only i successfully published my website at just $1.99 per year with various free options,visit this site for more details.
-
sowmika
- Aprendiz

-
- Mensagens: 39
- Registado: Quinta Abr 15, 2010 5:12
Voltar para Programação
Quem está ligado:
Utilizador a ver este Fórum: Nenhum utilizador registado e 1 visitante