Jump to content

JakeForDesign

New Members
  • Posts

    5
  • Joined

  • Last visited

JakeForDesign's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok thanks. Well what is the point in php self at all?
  2. I have my form created, and want to link it to an insert.php file where I can save data to database. Normally, I would have done it like this: <form method="post" action="insert.php"> Although, I have done my form a different way than usual to help security precautions(Reference: http://www.w3schools.com/php/php_form_complete.asp) <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name: <input type="text" name="name" value="<?php echo $name;?>"> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Website: <input type="text" name="website" value="<?php echo $website;?>"> <span class="error"><?php echo $websiteErr;?></span> <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <span class="error">* <?php echo $genderErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> My form's action attribute is filled with php code already, so where do I link to my insert.php file now? Can I still put a file name next to the php code that is already there? Can I do it like this, adding an onclick attribute that links to insert.php file?: <input type="submit" name="submit" value="Submit" onclick="insert.php">
  3. Wow thanks requinix. Yeah I knew I wasn't really using isset() correctly the way I was doing it above. I was following this netbeans wishlist tutorial and they were having me do it without isset at all! I'm glad you showed me the more logical way.
  4. I originally had the error: "undefined index: password" I researched the error and figured out that I needed to be using isset() When should I use isset(every time I use the post array?) Why does this prevent that error from showing up? Also, is this how I should be coding it: // Check whether a password was entered and confirmed correctly if (isset($_POST["password"])=="") { $passwordIsEmpty = true; } if (isset($_POST["password2"])=="") { $password2IsEmpty = true; } if (isset($_POST["password"])!= isset($_POST["password2"])) { $passwordIsValid = false; } Instead of: if ($_POST['password'] == "") { $passwordIsEmpty = true; } if ($_POST['password2'] == "") { $password2IsEmpty = true; } if ($_POST['password'] != $_POST['password2']) { $passwordIsValid = false; }
×
×
  • 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.