Jump to content

Search the Community

Showing results for tags 'blank'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. hi i want to put a validation in my code so it will check all fields if they have been used ive got the code pretty much sorted but they i think they is one problem with it on line 30 <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <? $con = mysqli_connect("","","",""); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } mysqli_query($con,"INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City); VALUES ('nelsons', 'luke', '', 'IT', '5 HIGHFIELD ROAD', 'LITTLEOVER', 'DERBY')"); mysqli_close($con); // define variables and set to empty values $companynameErr = $FirstNameErr = $Address1Err = $Address2Err = $AreaErr = $CityErr = ""; $companyname = $FirstName = $Address1 = $Address2 = $Area = $City = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") $allValid = true; if(validation fails); { $allValid = false; } if($allValid) { // connect to db, create query, execute query } As for checking the values you could if($_POST['companyname']==null || $_POST['companyname']=="") { $allValid = false; } ?> <form action="insertaddleads.php" method="post"> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> CompanyName: <input type="text" name="companyname"> <span class="error">* <?php echo $CompanyNameErr;?></span> <br><br> FirstName: <input type="text" name="firstname"> <span class="error">* <?php echo $FirstNameErr;?></span> <br><br> Address 1: <input type="text" name="address1"> <span class="error">* <?php echo $Address1Err;?></span> <br><br> Address 2: <input type="text" name="address2"> <span class="error">* <?php echo $Address2Err;?></span> <br><br> Area: <input type="text" name="area"> <span class="error">* <?php echo $AreaErr;?></span> <br><br> City: <input type="text" name="city"> <span class="error">* <?php echo $CityErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> <? echo $CompanyName; echo "<br>"; echo $FirstName; echo "<br>"; echo $Address1; echo "<br>"; echo $Address2; echo "<br>"; echo $Area; echo "<br>"; echo $City; echo "<br>"; ?> <?php foreach($_POST as $fieldName=>$fieldValue) { if($fieldValue == '') { print "<div>$fieldName is blank</div>"; } } ?> </body> </html> heres the insert just incase <?php $con=mysqli_connect("","","",""); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "record added"; mysqli_close($con); ?> <html> <body> <form action="addleads2.php" method="post"> <input type="submit", value = "go back"> </form> </body> </html>
  2. Hi, guys! I have a system developed in PHP and Flash. It is divided into layers (MVC). I'm facing the following issue: the form, which is done in Flash, sends data to PHP via POST. I threw an exception printing what is coming from the form. When I click "Save" the data come black. As what I filled out the form remains on the screen, if I click again on "Save" the data are sent normally. What can it be? Anyone got a light? Thanks in advance!
×
×
  • 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.