Jump to content

html/php


dan09

Recommended Posts

I was following your excellent tutorial on how to create a user login in and register.

The problem i have is when i load up the register.php file in the browser i get err messages like undefined index

I have looked at other peoples comments but cannot fix this issue.

Please can you help me? Thanks

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/242849-htmlphp/
Share on other sites

<?php
echo "<h1>Register</h1>";

$submit = $_POST['submit'];

if (isset($submit))
{

$fullname = $_POST['fullname'];
$username = $_POST['username'];
$password = $_POST['password'];
$repeatpassword = $_POST['repeatpassword'];	

echo "{$username}/{$password}/{$repeatpassword}/{$fullname}";
}

?>


<html>

<form action='/1/register.php' method='POST'>
<table>
    <tr>
    <td>
    Your full name:
    </td>
    <td>
    <input type='text' name'fullname'>
    </td>
    </tr>
     <tr>
    <td>
    Choose a username:
    </td>
    <td>
    <input type='text' name'username'>
    </td>
    </tr>
     <tr>
    <td>
    Choose a Password:
    </td>
    <td>
    <input type='password' name'password'>
    </td>
    </tr>
     <tr>
    <td>
    Repeat password:
    </td>
    <td>
    <input type='password' name'repeatpassword'>
    </td>
    </tr>
   
    </table>
    <p>
    <input type='submit' name 'submit' value='Register'>
</form>

</html>

 

this is most likely just a notice, and is triggered because you indices aren't being used until you submit the form...the best thing to do here is to check that the submit button has been set, then set your POST variables like I have don above

Link to comment
https://forums.phpfreaks.com/topic/242849-htmlphp/#findComment-1247373
Share on other sites

the index notice refers to $submit = $_POST['submit']

this is only a notice and can really be ignored in this case..basically by setting it to a variable you are initializing the $_POST index without that index having a value since you havn't submitted the form...this will not effect your script whatsoever

Link to comment
https://forums.phpfreaks.com/topic/242849-htmlphp/#findComment-1247393
Share on other sites

top of your php portion...okay so the action is correct..

if you want the errors to be displayed on your webpage instead of having to go to the error.log which you might even know where it is, put this as well on the top of you php code..

 

ini_set("display_errors","ON");

Link to comment
https://forums.phpfreaks.com/topic/242849-htmlphp/#findComment-1247429
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.