[PHP / HTML] Form not "POSTING" inputs (RESOLVED)

C++, C#, Java, PHP, ect...
Post Reply
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

[PHP / HTML] Form not "POSTING" inputs (RESOLVED)

Post by vitinho444 »

Hey guys, I'm building in my spare time a very simple service that might come handy in my country, even in the states i guess.

It's a website for reviews and rating for Universities and College courses that people can share their opinions, suggestions, pros and cons etc, and rate it so others can decide which one to attend.

It's almost ready but when i uploaded it to my host (http://www.oryzhon.com) the website went retarded for some reason.
In the register, it's not "POSTING" (method="post") the username, name and email of the user, just the password.
Can't seem to find the error :O But it should be easy since I had a error (jacko helped me) that i was asking for an ID instead of a NAME property of the input -.- .

Here's the code:

Code: Select all

if(isset($_SESSION["USER"]))
                    {
                        //User already logged on (lol noob trying to edit the url)
                        echo "<h2>Já tens uma conta registada.</h2>";
                    }
                    else if(isset($_POST["register"]))
                    {
                        //Register
//Protect string is: /*
function ProtectString($string)
{
    $string = trim(strip_tags(mysql_real_escape_string($string)));
    return $string;    
}    */
                        $username = ProtectString($_POST["user"]); 
                        $nome = ProtectString($_POST["nome"]);
                        $password = Encrypt(ProtectString($_POST["password"]));
                        $email = ProtectString($_POST["email"]);
                        
                        Debug($username); //this outputs nothing
                        Debug($nome); //this outputs nothing
                        Debug($password); //this outputs encrypted password not sure if encrypted nothing lol
                        Debug($email); //this outputs nothing
                    
                        
                        $checkUsername = $db->Execute("SELECT id FROM users WHERE username=?", $username);
                        //$tempUser = mysql_query("SELECT id FROM users WHERE username='$username'");
                        if($checkUsername->EOF)
                        {
                            $checkEmail = $db->Execute("SELECT * FROM users WHERE email=?", $email);
                            //$tempEmail = mysql_query("SELECT id FROM users WHERE email='$email'");
                            if($checkEmail->EOF)
                            {
                                $db->Execute("INSERT INTO `users`(`username`, `password`, `nome`, `email`) VALUES (?, ?, ?, ?)", $username, $password, $nome, $email);
                                
                                 //account created
                            }
                            else
                            {
                                 //theres a user with same email
                            }
                            $checkEmail->EOF;
                        }
                        else
                        {
                             //user with same username
                        }
                        $checkUsername->Close();
                    }
                    else
                    {
                        ?>
                        
                        <form method="POST" action="register.php">
                            <p class="label">Username</p>
                                <input class="register" type="text" name="user">
                            
                            <p class="label">Name</p>
                                <input class="register" type="text" name="name">
                            
                            <p class="label">Password</p>
                                <input class="register" type="password" name="password">
                                
                            <p class="label">Email</p>
                                <input class="register" type="text" name="email">

                            <br>
                            <input type="submit" class="button" name="register">
                        </form>
                        
                        <?php
                    }
It is working on my localhost why isn't it working on my website?
Last edited by vitinho444 on Sat Jul 06, 2013 12:52 pm, edited 1 time in total.
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by Jackolantern »

You spelled "name" and "nome", so I am not sure if that is intentional.

If we could see the form, I could look at it some more :)
The indelible lord of tl;dr
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by vitinho444 »

Jackolantern wrote:You spelled "name" and "nome", so I am not sure if that is intentional.

If we could see the form, I could look at it some more :)
Yeah nome is name in my language, i changed every sign of my language so you guys can understand better,
What you mean seeing the form?

www.oryzhon.com/uniopiniao/register.php
Like that? Try using google translator so you can understand :) (Portuguese to english)
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by Jackolantern »

Actually, please repost the code unaltered in Portuguese. Otherwise I can't compare it to the form data. And if you could post the form HTML, it would make it a bit easier than having to look at the source :cool:
The indelible lord of tl;dr
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by vitinho444 »

This is the whole page as it is.

Code: Select all

<?php
	session_start();
	ob_start();
	include 'config.php';
	include 'functions.php';
?>
<!DOCTYPE html>
<html>
	<head>
		<title>UniOpinião</title>
        <!-- META TAGS -->
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <meta name="description" content="Uniopiniao é um portal de opiniões, análises e criticas sobre Universidades Portuguesas.">
        <meta name="keywords" content="Portugal, Universidades, Faculdades, FCUL, IST, ISCTE, ISEL, UNL, Opiniao, Review, analise">
		<meta name="author" content="Vitor Pêgas">
        <!-- END META TAGS -->
        
        <link rel="stylesheet" type="text/css" href="css/style.css">
	</head>
	
	<body>
		<section id="container">
			<header>
				<span id="title"><a href="index.php" id="title">UniOpinião</a></span><span id="divide"></span><span id="subtitle">O portal de análises, criticas e opiniões sobre Universidades e Cursos em Portugal</span>
				<?php include 'nav.php'; ?>
			</header>
			
			<section id="content">
				<h1>Registo</h1>
				<?php
					if(isset($_SESSION["USER"]))
					{
						//Utilizador já se encontra registado e logado aparentemente
						echo "<h2>Já tens uma conta registada.</h2>";
					}
					else if(isset($_POST["register"]))
					{
						//Registar o utilizador
						$username = ProtectString($_POST["user"]);
						$nome = ProtectString($_POST["nome"]);
						$password = Encrypt(ProtectString($_POST["password"]));
						$email = ProtectString($_POST["email"]);
						
						Debug($username);
						Debug($nome);
						Debug($password);
						Debug($email);
					
						
						$checkUsername = $db->Execute("SELECT id FROM users WHERE username=?", $username);
						//$tempUser = mysql_query("SELECT id FROM users WHERE username='$username'");
						if($checkUsername->EOF)
						{
							$checkEmail = $db->Execute("SELECT * FROM users WHERE email=?", $email);
							//$tempEmail = mysql_query("SELECT id FROM users WHERE email='$email'");
							if($checkEmail->EOF)
							{
								$db->Execute("INSERT INTO `users`(`username`, `password`, `nome`, `email`) VALUES (?, ?, ?, ?)", $username, $password, $nome, $email);
								
								echo "<h2>A tua conta foi criada com sucesso! Usa a <a href='login.php'>página de acesso</a> para entrares na tua conta.</h2>";
							}
							else
							{
								echo "<h2>Já existe um utilizador com o mesmo email que tu. Por favor tenta um diferente.</h2>
								<h2><a href='register.php'>Voltar Atrás</a></h2>";
							}
							$checkEmail->EOF;
						}
						else
						{
							echo "<h2>Já existe um utilizador com o mesmo nome de utilizador que tu. Por favor tenta um diferente.</h2>
							<h2><a href='register.php'>Voltar Atrás</a></h2>";
						}
						$checkUsername->Close();
					}
					else
					{
						?>
						
						<form method="POST" action="register.php">
							<p class="label">Nome de Utilizador</p>
								<input class="register" type="text" name="user">
							
							<p class="label">Nome</p>
								<input class="register" type="text" name="nome">
							
							<p class="label">Palavra chave</p>
								<input class="register" type="password" name="password">
								
							<p class="label">Email</p>
								<input class="register" type="text" name="email">

							<br>
							<input type="submit" class="button" name="register">
						</form>
						
						<?php
					}	
				?>
			</section>
			
			<footer>
				<?php include 'footer.php'; ?>
			</footer>
		</section>
	</body>
	
	<script src="js/jquery-1.10.1.min.js"></script>
	<script src="js/mainJquery.js"></script>
</html>
sorry for the noob question but how can give you the HTML without the source?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by Jackolantern »

No hehe :) I wanted you to post the source of the HTML, untranslated, in case there was any PHP in it, which would not show up looking at the source through the browser.

EDIT: Oops, didn't see the form was on the same page lol! Ok, taking a look at it now.

EDIT2: Why are you checking for $_POST['register']? I don't see a field named that in the form.

EDIT3: Ohhh, I see. I never actually knew that about PHP lol. I never put a name on my submit buttons. Hmm...still looking.

What actual errors are you getting?
The indelible lord of tl;dr
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by vitinho444 »

Jackolantern wrote:No hehe :) I wanted you to post the source of the HTML, untranslated, in case there was any PHP in it, which would not show up looking at the source through the browser.

EDIT: Oops, didn't see the form was on the same page lol! Ok, taking a look at it now.

EDIT2: Why are you checking for $_POST['register']? I don't see a field named that in the form.

EDIT3: Ohhh, I see. I never actually knew that about PHP lol. I never put a name on my submit buttons. Hmm...still looking.

What actual errors are you getting?
First i use the register to check if the form was submitted :) instead of checking for a input that might be blank.

My problem is that the form is not submitting the name (nome) the username and the email. The password as it gets encrypted right away ($password = Encrypt($password)) i don't know if it's a blank encryption, but i assume the whole form is not being submitted.. But the submit button is submitting at least the POST register.

Should i do it from scratch ?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Lord Rahl
Posts: 93
Joined: Fri May 17, 2013 2:51 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by Lord Rahl »

Is it possibly something to do with the ProtectString() function? Var_dump() the values of them before you run it through, and then again after.
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by vitinho444 »

Lord Rahl wrote:Is it possibly something to do with the ProtectString() function? Var_dump() the values of them before you run it through, and then again after.
I got this:
string(8) "username"
string(4) "name"
string(8) "password"
string(5) "email"
the values between "" is the values i input. I guess it is the protect string that its not working... The protect string is just:

Code: Select all

function ProtectString($string)
{
	$string = trim(strip_tags(mysql_real_escape_string($string)));
	return $string;	
}	
What's wrong with that :D ?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: [PHP / HTML] Form not "POSTING" inputs

Post by vitinho444 »

Tried to write it from scratch, without Protect string and all, still doesn't work :(
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Post Reply

Return to “Coding”