Secret Experience

Secret Experience (https://secretexperience.net/)
-   [L2J] Pedidos (https://secretexperience.net/l2j-pedidos/)
-   -   [Web Site] Pagina de cadastro não envia ao banco de dados! (https://secretexperience.net/l2j-pedidos/33846-pagina-de-cadastro-nao-envia-ao-banco-de-dados.html)

FULL_LOL 03-07-2013 07:11 PM

Pagina de cadastro não envia ao banco de dados!
 
Montei esse painel de cadastro, mais as informações nao são enviadas ao banco de dados, onde esta o erro ?

Código:

<html>

<head>
<title>cadastro</title>
</head>

<boby>
<?php
//Desligando a noticia de erros
ini_set("display_errors", "OFF");

$host = "127.0.0.1";
$user = "root";
$pass = "";
$banco = "l2jdb";
$conexao = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($banco) or die(mysql_error());

$nome=$_POST['nome'];
$email=$_POST['email'];
$login=$_POST['login'];
$senha=$_POST['password'];
$divulgacao=$_POST['divulgacao'];
$sql = mysql_query("INSERT INTO accounts(nome, email, login, password, divulgacao);
VALUES('$nome', '$email', '$login', '$password', '$divulgacao')");
?>
<form name="signup" method="post" action="cadastro.php">
nome: <input type="text" name="nome" /> <br/>
E-mail: <input type="text" name="email" /> <br/>
login: <input type="text" name="login" /> <br/>

Senha: <input type="password" name="password" /> <br/>
Divulgaçãp: <input type="text" name="divulgacao" /> <br/>
<input type="submit" value="cadastrar" />

</form>
</boby>
</html>


Setokaiba 04-07-2013 11:31 AM

Posta a tabela para comparar os campos.

FULL_LOL 04-07-2013 12:32 PM

/*
Navicat MySQL Data Transfer

Source Server : localhost_3306
Source Server Version : 50612
Source Host : localhost:3306
Source Database : l2jdb

Target Server Type : MYSQL
Target Server Version : 50612
File Encoding : 65001

Date: 2013-07-04 12:31:10
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for `accounts`
-- ----------------------------
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts` (
`login` varchar(45) NOT NULL DEFAULT '',
`password` varchar(45) DEFAULT NULL,
`lastactive` decimal(20,0) DEFAULT NULL,
`access_level` int(11) DEFAULT NULL,
`lastIP` varchar(20) DEFAULT NULL,
`lastServer` int(4) DEFAULT '1',
`nome` varchar(45) DEFAULT '',
`email` varchar(45) DEFAULT '',
`divulgacao` varchar(45) DEFAULT '',
PRIMARY KEY (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Setokaiba 04-07-2013 12:59 PM

ini_set("display_errors", "OFF");

Ponha ON e veja qual erro é apontado.

FULL_LOL 04-07-2013 01:05 PM

Link da imagem!
[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]


( ! ) Notice: mysql_connect(): SQL safe mode in effect - ignoring host/user/password information in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 16
Call Stack
# Time Memory Function Location
1 0.0010 143304 {main}( ) ..\cadastro.php:0
2 0.0010 144232 mysql_connect ( ) ..\cadastro.php:16

( ! ) Notice: Undefined index: nome in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 19
Call Stack
# Time Memory Function Location
1 0.0010 143304 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: email in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 20
Call Stack
# Time Memory Function Location
1 0.0010 143304 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: login in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 21
Call Stack
# Time Memory Function Location
1 0.0010 143304 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: password in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 22
Call Stack
# Time Memory Function Location
1 0.0010 143304 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: divulgacao in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 23
Call Stack
# Time Memory Function Location
1 0.0010 143304 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined variable: password in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 25
Call Stack
# Time Memory Function Location
1 0.0010 143304 {main}( ) ..\cadastro.php:0




quando clico em cadastra, da esse erro aqui

( ! ) Notice: mysql_connect(): SQL safe mode in effect - ignoring host/user/password information in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 16
Call Stack
# Time Memory Function Location
1 0.0030 146448 {main}( ) ..\cadastro.php:0
2 0.0030 147368 mysql_connect ( ) ..\cadastro.php:16

( ! ) Notice: Undefined variable: password in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 25
Call Stack
# Time Memory Function Location
1 0.0030 146448 {main}( ) ..\cadastro.php:0


O Google tinha traduzido :realmad:

Setokaiba 04-07-2013 03:39 PM

MySQL Connect dando erro por causa da senha desse user root.


$host = "127.0.0.1";
$user = "root";
$pass = "";
$banco = "l2jdb";
$conexao = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($banco) or die(mysql_error());

FULL_LOL 04-07-2013 03:57 PM

Pois e, mais o banco de dados não tem senha!

Setokaiba 04-07-2013 04:20 PM

Então crie uma senha... O script não se conecta sem senha.
Pront de comando:
Código:

prompt> mysql -u root mysql
  Reading table information for completion of table and column names
  You can turn off this feature to get a quicker startup with -A
 
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 3 to server version: 3.23.49-log
 
  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
  mysql>
  mysql>
  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('senha');
  Query OK, 0 rows affected (0.00 sec)
 
  mysql>


FULL_LOL 04-07-2013 04:33 PM

Criei a senha pelo phpmyadmin

já Coloquei a senha root na index do arquivo


( ! ) Notice: Undefined index: nome in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 19
Call Stack
# Time Memory Function Location
1 0.0020 143560 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: email in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 20
Call Stack
# Time Memory Function Location
1 0.0020 143560 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: login in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 21
Call Stack
# Time Memory Function Location
1 0.0020 143560 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: password in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 22
Call Stack
# Time Memory Function Location
1 0.0020 143560 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined index: divulgacao in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 23
Call Stack
# Time Memory Function Location
1 0.0020 143560 {main}( ) ..\cadastro.php:0

( ! ) Notice: Undefined variable: password in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 25
Call Stack
# Time Memory Function Location
1 0.0020 143560 {main}( ) ..\cadastro.php:0


Quando clica em registrar!


( ! ) Notice: Undefined variable: password in F:\wamp\www\Index_Projetos\novo cadastro\cadastro.php on line 25
Call Stack
# Time Memory Function Location
1 0.0020 146488 {main}( ) ..\cadastro.php:0

Setokaiba 05-07-2013 11:13 AM

Se você utiliza os quadros $_POST ou $_GET para recuperar as variáveis de seus formulários ou outros, pode acontecer que você caia neste erro:
Citação:

( ! ) Notice: Undefined variable:
Que significa: Instrução: Undefined index 'campo do quadro' in 'caminho do arquivo PHP em andamento on line 'linha em andamento'

Para evitar este erro basta testar se este campo do quadro foi inicializado com a função isset ().

Código:

Exemplo para uma variável $_POST['password']:
// Antes de utilizar  $_POST['password'] 
if (isset($_POST['password'])) 

          // Descrição se $_POST['truc'] existe 
}



Horários baseados na GMT -3. Agora são 10:02 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.