-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
Note that the autofocus attribute only works in newer browsers like Internet Explorer 10. Did you switch browsers? More information about the attribute and it's browser support can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input Also, it looks like the attribute is being added like you're using XHTML. If your page is set to be HTML 5, try changing autofocus="autofocus" ...to just autofocus
-
Need help with empty field error message
cyberRobot replied to outdoorxtreme's topic in PHP Coding Help
The message is currently set to display when the number is not empty. Try removing the not operator (!): if( empty($_POST['number'])) echo "You must enter a number to send to"; Also, I would recommend checking out the following article which talks about the security risks with using PHP_SELF as a form action: http://seancoates.com/blogs/xss-woes -
Assuming that the GET variable (x) is always a number, you can run a simple test before using the value. <?php //IF AN ID WAS PASSED --AND-- IT'S A NUMBER if(isset($_GET['x']) && ctype_digit((string)$_GET['x'])) { //RUN CODE TO PROCESS x //ELSE...LET USER KNOW THE ID IS INVALID } else { //ERROR MESSAGE HERE } ?> More information about ctype_digit() can be found here: http://www.php.net/manual/en/function.ctype-digit.php
-
Have you tried using an actual submit button? http://www.echoecho.com/htmlforms12.htm Also note that your input fields need to include the "name" attribute. Otherwise PHP won't be able to access the values sent through the form.
-
Sorry, just a few more quick notes. First, you have a duplicate line here (it's processing $email twice): $safe_email = mysqli_real_escape_string($email); $safe_password = mysqli_real_escape_string($password); $safe_email = mysqli_real_escape_string($email); Also, the form labels currently aren't doing anything. Perhaps the following will help with connecting the <label> tag to the corresponding <input> tag: http://www.cyberscorpion.com/2012-02/making-html-forms-more-accessible-and-improving-usability-with-the-label-tag/
-
There are a few errors with the query. It's enclosed within single quotes. Since you have PHP variables in the query, you'll need to use double quotes. The query doesn't specify the value for the "id" column. The query just leaves it blank. If you run mysql_error(), you should get an error. The list of columns need to match the list of values...and in the same order. Assuming that the "id" column auto-increments, try changing you query to mysqli_query("INSERT INTO users (name, surname, username, password, email) VALUES ($safe_name, $safe_surname, $safe_username, $safe_password, $safe_email)"); Side notes: PHP has a function for validating email addresses: http://www.php.net/manual/en/filter.examples.validation.php The mysql_ functions have been depreciated; at some point you'll need to look into the alternatives: http://www.php.net/manual/en/mysqlinfo.api.choosing.php
-
You should only need to develop a single form. The script that generates the form would just read in the ID, make sure it's valid, and pass it along with the rest of the form submission. The ID could be saved to a hidden variable, for example. Then the script which processes the form would get the ID from the form and connect it with the corresponding customer account.
-
If you're trying to get the images to rotate without the page reloading, you'll need to use a client-side scripting language like JavaScript. https://www.google.com/search?q=javascript+rotating+images You can still use PHP to get the image information, you'll just need to load it into JavaScript.
-
There are quite a few syntax errors in the PHP code. Are you getting any errors? For what it's worth, the if statements should look more like this: if(isset($_GET['first'])) { $firstname = $_GET['first']; } else { $firstname = ''; } You could also consider using the Ternary Operator: if($_GET) { //Define Variables $firstname = (isset($_GET['first'])) ? $_GET['first'] : ''; $lastname = (isset($_GET['last'])) ? $_GET['last'] : ''; $bibsearch = (isset($_GET['bib'])) ? $_GET['bib'] : ''; $divsearch = (isset($_GET['division'])) ? $_GET['division'] : ''; $sex = (isset($_GET['sex'])) ? $_GET['sex'] : ''; }
-
Posting Form information to Database with PHP
cyberRobot replied to deadendstreet's topic in PHP Coding Help
Also note that your form fields are named differently from your POST variables. For example, here the field is named "program" <input name="program" type="text" id="program" /> And the POST variable is named "Program" $_POST['Program'] -
Have you tried enabling errors? http://www.php.net/manual/en/function.error-reporting.php http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
-
It looks like you're trying to have someone log in using the form. Once the form is submitted, you want to pull the user's information from the database which corresponds with the passed log in. If that's the case, you'll need to use $_POST variables since the form is set to POST. Once you're familiar with using POST variables, you'll need to add them to a WHERE clause in your query. Don't forget to use mysql_real_escape_string(): http://www.php.net/mysql_real_escape_string
-
Note that the close </a> tag needs to go inside the close </li> tag. <?php echo '<ul class=...."'; while($company = mysql_fetch_array($query)) { echo "<li><a href=\"#\">" . $company['t1'] . "</a></li>"; //<-- NOTE: close </a> tag was moved inside the close </li> tag } echo '</ul>'; ?>
-
You could start here: http://www.if-not-true-then-false.com/2009/php-loop-through-dates-from-date-to-date-with-strtotime-function/
-
How do i make a pause and play even on page refresh
cyberRobot replied to lovephp's topic in Javascript Help
Have you tried using clearTimeout()? There's an example of what it sounds like you want to do here: https://developer.mozilla.org/en-US/docs/Web/API/window.setTimeout -
You could use PHP sessions: http://www.php.net/manual/en/intro.session.php
-
If you haven't done so already, I would recommend looking into the following: mysql_real_escape_string() Validating email addreses: http://www.php.net/manual/en/filter.examples.validation.php
-
Note that I moved your question to the PHP Coding Help section. As for your code, the part which adds the <span> tag isn't formatted correctly. It should look more like this: echo '<span class="' . $tag->name . '">' . $tag->name . '</span> '; Note that I moved the close </span> tag inside your foreach loop.
-
It looks like you defined $tData here: //... //Set initial output to false $tData = false; foreach($xml->report as $report) //...
-
Note that there are multiple levels of error reporting. Perhaps the following will help: http://www.php.net/manual/en/function.error-reporting.php Also note that there's a setting which determines whether or not those errors are displayed to the screen: http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
-
looping through multidimensional array -- help
cyberRobot replied to stevieontario's topic in PHP Coding Help
You should be able to use your existing variables to access the "Capabilities" part of the array. I haven't spent too much time trying to figure out the array or the loop that processes it, but you could try using the following in the echo statement: $machine['Capabilities']['Capability'][$k]; Also note that you can get a better idea of how to work with the array, by using the following line: echo '<pre>' . print_r($arrayGoesHere, true) . '</pre>'; You just need to plug in the array you want to see. You could add the following lines of code somewhere in your loop after the $machine variable is created: echo '<pre>' . print_r($machine['Capabilities'], true) . '</pre>'; echo '<pre>' . print_r($machine['Capabilities']['Capability'], true) . '</pre>'; -
Block or Dissallow http string in Contact Form Message Box
cyberRobot replied to AndreD's topic in PHP Coding Help
You don't think your normal customers would ever type a website address? For example, would the form ever be used to report a broken link on the website? As for what you could use to see if a message contains a certain string, you could try strpos() or preg_match(). -
It looks like you have one form which contains many input fields named "vid". Unless I'm missing something, that's not going to work. When the form is submitted, only the last value will be passed through the form. Instead, I would recommend looking into using anchor tags for the action buttons. For example, you could try something like the following: <?php if(isset($result)){ while($row = mysqli_fetch_array($result)){ echo '<tr>'; echo "<td>{$row['id']}</td>"; echo "<td>{$row['name']}</td>"; echo "<td>{$row['firstname']}</td>"; echo "<td>{$row['age']}</td>"; echo "<td><a href='data.php?update=1&vid={$row['id']}'>Update</a> <a href='data.php?delete=1&vid={$row['id']}'>Delete</a></td>"; echo '</tr>'; } } ?> Then on the data.php page, you could see which link was clicked by doing something like this: <?php if(isset($_GET['update'])) { //do update stuff } elseif(isset($_GET['delete'])) { //do delete stuff } ?>
-
I don't see any $_POST variables, so perhaps the following will help: http://www.tizag.com/phpT/postget.php
-
Before adding the entry, you could run a query to check if they already liked the page. Just run a search that looks for an entry with the selected news post's ID and the username. If a match isn't found, run your insert query. Additionally, you could replace the "Like" button with something else (maybe an Unlike button) if the visitor already liked the news story they are currently viewing. You would run the same query as described above.