Topic: Basic sign in help...

I followed on of Stefan's videos (about processing forms) and I've had a few difficulties.

After I fill in the form there is never anything on the other page. I'll show you my source code and maybe you can tell me where I' going wrong.

form.php wrote:

<html>
<head>
<title>Sign up!</title>
<style type="text/css">
img {
border: none;
}
</style>
</head>
<body>
<div style="padding:15px; border:1px solid #303030; background

<form method="post" action="form_response.php">
<div class="form_element_div">
First name:<br> <input name="name_first" type="text" size="50" maxlength="200">
</div>
<div class="form_element_div">
Email: <br><input name="email" type="text" size="50" maxlength="200">
</div>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>

As you can see this is my actual form page. And that it SHOULD be sending the information put into the form to "form_response.php". But it never does.

Now I'll show you the actual response code.

form_response.php wrote:

<html>
<head>
</head>
<body>

<?php

print $_POST['name_first'];


?>
</body>
</html>

All I want it to do is just paste what name is input into the "First name:" field on the form page. But it doesn't. hmm

I thank you in advance and if you need anymore information just ask for it. smile

Vote up Vote down

Re: Basic sign in help...

I'm guessing that this line from your example is incomplete (and it isn't causing your error):

<div style="padding:15px; border:1px solid #303030; background

Where are you trying to run this code? On your web host? On your computer? If you are running it on your computer, you realize you'll need something like MAMP (mac) or WAMP (PC) in order to run PHP scripts? And, if you have that installed, the files you are running need to be placed in a specific location on your computer in order for the server to process the PHP code?

This code works fine on my computer.

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Basic sign in help...

Indeed, I have XAMPP on my computer. I go to the location for the form and then go to the location for the the form response and still nothing. Even if the response is in my tabs and after I do my form nothing is displayed in the response part which is what I want.

Vote up Vote down

Re: Basic sign in help...

Where are you saving the PHP files?

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Basic sign in help...

C:\xampp\htdocs\xampp

I can get on the actual page, but after submitting the form I can't see the name that has been input.

Vote up Vote down

Re: Basic sign in help...

Are you sure that the server is on? Can you run other PHP code correctly? Other PHP code that uses GET or POST? As I said, your code example worked just fine for me.

And, according to your path, you are trying to access this file (with the server on) using http://localhost/xampp/form.php?

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Basic sign in help...

Yes that is the site I go to for the form. The form appears and I can fill it in and submit it and whatnot. But when I go: http://localhost/xampp/form_response.php?
What I've put into my form is not shown there. Is it shown for you? (only the name of course as that's all I'm asking for).

Vote up Vote down

Re: Basic sign in help...

The code itself is fine -- it works fine for me.  As I said above, can you run other PHP code correctly? Other PHP code that uses GET or POST?

For example, what happens when you view a file in localhost that has this contents:

<?php phpinfo(); ?>

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Basic sign in help...

A clarification... The only time I get a blank screen for the form_response file is if:

-- I haven't visited form.php first and entered information/hit submit
-- If I try to access the file directly in c:\xampp\etc rather than through localhost
-- if the server isn't turned on (and I try to access the file directly, since obviously localhost won't work)
-- If the file ends in .html rather than .php

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Basic sign in help...

falkencreative wrote:

The code itself is fine -- it works fine for me.  As I said above, can you run other PHP code correctly? Other PHP code that uses GET or POST?

For example, what happens when you view a file in localhost that has this contents:

<?php phpinfo(); ?>

That shows the contents table showing the php info.

So it is just the code for me not working. :S

Vote up Vote down

Re: Basic sign in help...

Dunno. It sounds like you are doing the right things.  The code itself looks fine and runs fine on my machine. You may try reinstalling XAMPP, or removing it and installing WAMP (in general I have found that people seem to have less trouble with WAMP.)

http://www.wampserver.com/

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Basic sign in help...

Will do then. smile
Will post results.

Vote up Vote down

Re: Basic sign in help...

falkencreative wrote:

Dunno. It sounds like you are doing the right things.  The code itself looks fine and runs fine on my machine. You may try reinstalling XAMPP, or removing it and installing WAMP (in general I have found that people seem to have less trouble with WAMP.)

http://www.wampserver.com/

Wait sorry, didn't see the language change at the side.

Last edited by Lewicide (August 18, 2009 6:09 pm)

Vote up Vote down

Re: Basic sign in help...

I don't really want to have to watch another video on WAMP. Where do you put the folders to view them from localhost?

Vote up Vote down

Re: Basic sign in help...

This should get you started: http://www.wampserver.com/en/presentation.php

"When you install WampServer, a "www" directory is created (generally c:\wamp\www). Create a directory inside for your project and put your PHP files in it. "

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down

Re: Basic sign in help...

I'll watch a tut on what to do later as I'm having trouble setting it up right now. But the temptation of watching South Park is too strong. lol

Vote up Vote down

Re: Basic sign in help...

Hi,

After you install wamp. you will see a folder called www inside the wamp installation directory. create a folder called test inside www. then create a file called index.php and paste this code there.
then put: http://localhost/test/index.php in your browser, then you will see a form you have created. Input the first name and email value and submit you should see the result in the same page.

If you have installed xampp please create a folder inside the htdocs directory and not inside the xampp folder. Though it is valid but it is not good to create a project folder in xampp directory.
then run http://localhost/test/index.php in the browser and you will see the same result as above.

   <?php
   if(isset($_POST['Submit'])){
    echo "<b>First Name: </b>".$_POST['name_first']."<br>";
    echo "<b>Email:</b> ".$_POST['email']."<br>";
   } 
   ?>
    <html>
    <head>
    <title>Sign up!</title>
    <style type="text/css">
    img {
    border: none;
    }
    </style>
    </head>
    <body>
    <div style="padding:15px; border:1px solid #303030; background">
    <form method="post" action="" name="test">
    <div class="form_element_div">
    First name:<br> <input name="name_first" type="text" size="50" maxlength="200">
    </div>
    <div class="form_element_div">
    Email: <br><input name="email" type="text" size="50" maxlength="200">
    </div>
    <input type="submit" value="Submit" name="Submit">
    <input type="reset" value="Reset">
    </form>
    </body>
    </html>

Vote up Vote down

Re: Basic sign in help...

bishwadeep wrote:

Hi,

After you install wamp. you will see a folder called www inside the wamp installation directory. create a folder called test inside www. then create a file called index.php and paste this code there.
then put: http://localhost/test/index.php in your browser, then you will see a form you have created. Input the first name and email value and submit you should see the result in the same page.

If you have installed xampp please create a folder inside the htdocs directory and not inside the xampp folder. Though it is valid but it is not good to create a project folder in xampp directory.
then run http://localhost/test/index.php in the browser and you will see the same result as above.

   <?php
   if(isset($_POST['Submit'])){
    echo "<b>First Name: </b>".$_POST['name_first']."<br>";
    echo "<b>Email:</b> ".$_POST['email']."<br>";
   } 
   ?>
    <html>
    <head>
    <title>Sign up!</title>
    <style type="text/css">
    img {
    border: none;
    }
    </style>
    </head>
    <body>
    <div style="padding:15px; border:1px solid #303030; background">
    <form method="post" action="" name="test">
    <div class="form_element_div">
    First name:<br> <input name="name_first" type="text" size="50" maxlength="200">
    </div>
    <div class="form_element_div">
    Email: <br><input name="email" type="text" size="50" maxlength="200">
    </div>
    <input type="submit" value="Submit" name="Submit">
    <input type="reset" value="Reset">
    </form>
    </body>
    </html>

Booya! Thank's a lot. smile
I don't think you can give rep on this site, else I'd be chucking it at you (and of course and the moderator who helped me a lot and also put up with me not really understanding). big_smile

Vote up Vote down