Jump to content

bremen1984

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bremen1984's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi all i have a Register form that is driving me crazy, i have been working on this for 2 days now and not getting any where. it keeps running this code: } else { // If it did not run OK. echo '<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; and i do not get why. here is the full code hope some one can help. thanks <?php # Script 16.6 - register.php // This is the registration page for the site. require_once ('includes/config.inc.php'); $page_title = 'Register'; include ('includes/header.html'); if (isset($_POST['submitted'])) { // Handle the form. require_once (MYSQL); // Trim all the incoming data: $trimmed = array_map('trim', $_POST); // Assume invalid values: $cn = $lc = $fn = $ln = $e = $p = FALSE; // Check for a Company Name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['company_name'])) { $cn = mysqli_real_escape_string ($dbc, $trimmed['company_name']); } else { echo '<p class="error">Please enter your Company name!</p>'; } // Check for a location: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['location'])) { $lc = mysqli_real_escape_string ($dbc, $trimmed['location']); } else { echo '<p class="error">Please enter your State and City!</p>'; } // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) { $fn = mysqli_real_escape_string ($dbc, $trimmed['first_name']); } else { echo '<p class="error">Please enter your first name!</p>'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimmed['last_name'])) { $ln = mysqli_real_escape_string ($dbc, $trimmed['last_name']); } else { echo '<p class="error">Please enter your last name!</p>'; } // Check for an email address: if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'])) { $e = mysqli_real_escape_string ($dbc, $trimmed['email']); } else { echo '<p class="error">Please enter a valid email address!</p>'; } // Check for a password and match against the confirmed password: if (preg_match ('/^\w{4,20}$/', $trimmed['password1']) ) { if ($trimmed['password1'] == $trimmed['password2']) { $p = mysqli_real_escape_string ($dbc, $trimmed['password1']); } else { echo '<p class="error">Your password did not match the confirmed password!</p>'; } } else { echo '<p class="error">Please enter a valid password!</p>'; } if ($cn && $lc && $fn && $ln && $e && $p) { // If everything's OK... // Make sure the email address is available: $q = "SELECT user_id FROM users WHERE email='$e'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_num_rows($r) == 0) { // Available. // Create the activation code: $a = md5(uniqid(rand(), true)); // Add the user to the database: $q = "INSERT INTO users (company_name, location, email, pass, first_name, last_name, active, registration_date, ) VALUES ('$e', SHA1('$p'), '$cn', '$lc', '$fn', '$ln', '$a', NOW() )"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. // Send the email: $body = "Thank you for registering at <Eclipse Media>. To activate your account, please click on this link:\n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'], 'Registration Confirmation', $body, 'From: info@eclipsemedia.us'); // Finish the page: echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; include ('includes/footer.html'); // Include the HTML footer. exit(); // Stop the page. } else { // If it did not run OK. echo '<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; } } else { // The email address is not available. echo '<p class="error">That email address has already been registered. If you have forgotten your password, use the link at right to have your password sent to you.</p>'; } } else { // If one of the data tests failed. echo '<p class="error">Please re-enter your passwords and try again.</p>'; } mysqli_close($dbc); } // End of the main Submit conditional. ?> <h1>Register</h1> <form action="register.php" method="post"> <fieldset> <p><b>Company Name:</b> <input type="text" name="company_name" size="20" maxlength="20" value="<?php if (isset($trimmed['company_name'])) echo $trimmed['company_name']; ?>" /></p> <p><b>State City:</b> <input type="text" name="location" size="20" maxlength="20" value="<?php if (isset($trimmed['location'])) echo $trimmed['location']; ?>" /></p> <p><b>First Name:</b> <input type="text" name="first_name" size="20" maxlength="20" value="<?php if (isset($trimmed['first_name'])) echo $trimmed['first_name']; ?>" /></p> <p><b>Last Name:</b> <input type="text" name="last_name" size="20" maxlength="40" value="<?php if (isset($trimmed['last_name'])) echo $trimmed['last_name']; ?>" /></p> <p><b>Email Address:</b> <input type="text" name="email" size="30" maxlength="80" value="<?php if (isset($trimmed['email'])) echo $trimmed['email']; ?>" /></p> <p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="20" /> <small>Use only letters, numbers, and the underscore. Must be between 4 and 20 characters long.</small></p> <p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="20" /></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Register" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form> <?php // Include the HTML footer. include ('includes/footer.html'); ?> MOD EDIT: code tags added
  2. there are no errors, it just takes me back to the login page, i have fix it and here is the new code. i can get it to ask for the login info but after they have loged in it will ask for the login every time the push the link is there a way that i can have it ask once and then after they log out or close the browser, it will ask again? here is the code. <?php session_start(); // Check if user is logged-in. if(isset($_SESSION['username'])){ // User is logged in $link_to = $_SESSION['username']."_page.php"; } else{ // User is not logged-in, so send them away. header ("location: login.php"); } // The rest of your page here ... ?>
  3. hi all i have a code that i am trying to password to protect my webpage and i cant seen to get it to coonect to mysql DB. here is the code $c_username = "root"; $c_password = "Steph1989"; $c_host = "localhost"; $c_database = "eclipse_media"; // Connect. $connection = mysql_connect($c_host, $c_username, $c_password) or die ("It seems this site's database isn't responding."); mysql_select_db($c_database) or die ("It seems this site's database isn't responding.");
  4. never mind i got it using this code thanks. <div style="width: 190px; height: 190px; overflow: auto; padding: 5px"> content in here </div>
  5. ok i get what you are saying i think, that is not what i am asking. see in my web site i do not have much room for the echo results so i was thinking that if i was to echo them in a textara or add a scrollbar then they can fit on my site. i was think of like in an email form there is a scrollbar that one can move to see all that is there. i hope that clear's thing up. <?php /*Open the connection to our database use the info from the config file.*/ $link = mysql_connect("localhost", "root", "Steph1989"); //connect to the database mysql_select_db("eclipse_media"); $sql = "SELECT company_name, contact_name, address, street_number, postcode, contact_number, contact_email, budget, description FROM 3dartactforms"; $results = mysql_query($sql); if (!$results) { die('Invalid query: ' . mysql_error()); } echo '<h3>3D art ACT</h3>'; while($result = mysql_fetch_array( $results )){ echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 5px;">'; echo date("d/m/y"); echo '<p>Company Name: ' . $result['company_name'] . '</p>'; echo '<p>Contact Name: ' . $result['contact_name'] . '</p>'; echo '<p>Address: ' . $result['address'] . '</p>'; echo '<p>Street Number: ' . $result['street_number'] . '</p>'; echo '<p>Postcode: ' . $result['postcode'] . '</p>'; echo '<p>Contact Number: ' . $result['contact_number'] . '</p>'; echo '<p>Contact Email: ' . $result['contact_email'] . '</p>'; echo '<p>Budget: ' . $result['budget'] . '</p>'; echo '<p>Description: ' . $result['description'] . '</p>'; echo '</div>'; } ?>
  6. ok so i have tried to echo out all of it in a textarea but it is not working can someone help pleas.
  7. ok thanks i got the echo scropt working, but i need help with it echoing in the textarea, can get more help pleas.
  8. can some one direct me to a good tut on echoing the form data i have looked on yahoo shearch, youtub, google, and many more so i do not know what else to do.
  9. ok sorry i posted the wrong script, here is the right one. <?php error_reporting(0); require_once('demo.php'); /*Open the connection to our database use the info from the config file.*/ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); $sql = "SELECT company_name, contact_name, address, street_number, postcode, contact_number, contact_email, budget, description FROM 3dartactforms"; $results = mysql_query($sql); if (!$results) { die('Invalid query: ' . mysql_error()); } echo '<h3>3D art ACT</h3>'; while($result = mysql_fetch_array( $results )){ echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 10px;">'; echo '<p>Company Name: ' . $result['company_name'] . '</p>'; echo '<p>Contact Name: ' . $result['contact_name'] . '</p>'; echo '<p>Address: ' . $result['address'] . '</p>'; echo '<p>Street Number: ' . $result['street_number'] . '</p>'; echo '<p>Postcode: ' . $result['postcode'] . '</p>'; echo '<p>Contact Number: ' . $result['contact_number'] . '</p>'; echo '<p>Contact Email: ' . $result['contact_email'] . '</p>'; echo '<p>Budget: ' . $result['budget'] . '</p>'; echo '<p>Description: ' . $result['description'] . '</p>'; echo '</div>'; } ?>
  10. if there is data in the database it will echo it fine it just, displays blank data if i refresh the page. and to be frank it is all the code fro my echo script.
  11. hi all i am having a big problem that i have been trying to find out what is going on for weeks. i have a echo script that echos data that is in my database, and if i have to refresh the page it will add blank data in my database and the top echo info is blank as well. how can i fix this, and i was wanting to know how do i echo out my info in a textarea. i added a jepg to show you what i mean. here is my code echoforms.php <?php error_reporting(0); require_once('demo.php'); /*Open the connection to our database use the info from the config file.*/ $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); $sql = "SELECT company_name, contact_name, address, street_number, postcode, contact_number, contact_email, budget, description FROM 3dartactforms"; $results = mysql_query($sql); if (!$results) { die('Invalid query: ' . mysql_error()); } while($result = mysql_fetch_array( $results )){ echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 10px;">'; echo date("d/m/y"); echo '<p>Company Name: ' . $_POST['company_name'] . '</p>'; echo '<p>Contact Name: ' . $_POST['contact_name'] . '</p>'; echo '<p>Address: ' . $_POST['address'] . '</p>'; echo '<p>Street Number: ' . $_POST['street_number'] . '</p>'; echo '<p>Postcode: ' . $_POST['postcode'] . '</p>'; echo '<p>Contact Number: ' . $_POST['contact_number'] . '</p>'; echo '<p>Contact Email: ' . $_POST['contact_email'] . '</p>'; echo '<p>Budget: ' . $_POST['budget'] . '</p>'; echo '<p>Description: ' . $_POST['description'] . '</p>'; echo '</div>'; } ?> [attachment deleted by admin]
  12. hi all i am new to the site and i to am having the same problem that Johnnyboy123 is having ii have looked all over the net for 3 weeks now and cant find any thing at all i need some ones help pleas and fast. here is all of my code.. Basicly I have a form which sends info to my database table after submitted. I added some form validation so when the user didn't enter a required field, text appears stating that the field needs to be entered. However, whether the field is entered or not, if the user submits the info still goes to the database. How do I fix it so that it only sends the info to the database once the required fields are entered? Do I go about it with an if statement? Demo.php <?php session_start(); if(!isset($_REQUEST['Hompage'])){ echo "<center>Your information has been sent please click on the link to take you back to the Homepage.</center><br />"; echo "<center><a href=index3dart.php>Home."; } define('DB_NAME', 'Eclipse_media'); define('DB_USER', 'root'); define('DB_PASSWORD', 'Steph1989'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die('Can\'t use ' . DB_NAME . ': ' . mysql_error()); } $value = $_POST['company_name']; $value2 = $_POST['contact_name']; $value3 = $_POST['address']; $value4 = $_POST['street_number']; $value5 = $_POST['postcode']; $value6 = $_POST['contact_number']; $value7 = $_POST['contact_email']; $value8 = $_POST['budget']; $value9 = $_POST['description']; $sql = "INSERT INTO 3dartactforms (company_name, contact_name, address, street_number, postcode, contact_number, contact_email, budget, description) VALUES ('$value', '$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8', '$value9')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close(); ?> form.php <?php error_reporting(0); $errors = array(); // set the errors array to empty, by default $fields = array(); // stores the field values $success_message = ""; if (isset($_POST['submit'])) { // import the validation library require("validation.php"); $rules = array(); // stores the validation rules // standard form fields $rules[] = "required,company_name,Company Name is required."; $rules[] = "required,contact_name,Contact Name is required."; $rules[] = "required,contact_email,Please enter your email address."; $rules[] = "valid_email,email,Please enter a valid email address."; $rules[] = "required,street_number,Street Number is required."; $rules[] = "required,address,Address is required."; $rules[] = "required,postcode,Postcode is required."; $rules[] = "required,contact_number,Contact Number is required."; $rules[] = "required,budget,Budget is required."; $rules[] = "required,description,Description is required."; $errors = validateFields($_POST, $rules); // if there were errors, re-populate the form fields if (!empty($errors)) { $fields = $_POST; } // no errors! redirect the user to the thankyou page (or whatever) else { $message = "All fields have been validated successfully!"; // here you would either email the form contents to someone or store it in a database. // To redirect to a "thankyou" page, you'd just do this: // header("Location: thanks.php"); } } ?> <style type="text/css"> <!-- body,p,table,td,input,select { font-family: verdana, tahoma; font-size: 8pt; line-height: 14pt; } .demoTable { background-color: #efefef; width: 100%; } .title { font-family: arial; font-size: 16pt; } .section { font-size: 11pt; color: #3366cc; } .error { border: 1px solid red; background-color: #ffffee; color: #660000; width: 400px; padding: 5px; } .notify { border: 1px solid #336699; background-color: #ffffee; color: #336699; width: 400px; padding: 5px; } --> </style> <table cellspacing="0" width="600" align="center"> <tr> <td> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <?php // if $errors is not empty, the form must have failed one or more validation // tests. Loop through each and display them on the page for the user if (!empty($errors)) { echo "<div class='error' style='width:100%;'>Please fix the following errors:\n<ul>"; foreach ($errors as $error) echo "<li>$error</li>\n"; echo "</ul></div>"; } if (!empty($message)) { echo "<div class='notify'>$success_message</div>"; } ?> <p>3D Graphics ACT</p> <form class="cmxform" id="signupForm" method="post" action=""> <fieldset> <p> <label for="firstname">Company Name:</label> <input id="company_name" name="company_name" /> </p> <p> <p> <label for="lastname">Contact Name:</label> <input id="contact_name" name="contact_name" /> </p> <p> <p> <label for="email">Email</label> <input id="email" name="contact_email" /> </p> <p> <p> <label for="streetnumber">Street Number:</label> <input id="street_number" name="street_number" /> </p> <p> <p> <label for="address">Address:</label> <input id="address" name="address" /> </p> <p> <p> <label for="postcode">Postcode:</label> <input id="postcode" name="postcode" /> </p> <p> <p> <label for="contact_number">Contact Number:</label> <input id="contact_number" name="contact_number" /> </p> <p> <p> <label for="budget">Budget:</label> <input id="budget" name="budget" /> </p> Description: <textarea rows="10" cols="40" name="description"></textarea></p> <p> <p> <p> <input type="submit" name="submit" value="SUBMIT" /></p> </form>
  13. hi Johnnyboy123 i am having that same thing happening to me i have been working on it for over 3 weeks now, could i ask if i can see all of your code and page names. pleas it would help me to see how it all linked, and might make it click in my brain. please please thanks.
×
×
  • 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.