Jump to content

Search the Community

Showing results for tags 'php'.

  • 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

  1. Hi, I am trying to connect to a database using mysqli from a web developing software package called Sellerdeck. This software is purely windows based, it has PHP configured to a certain extent it seems. I ran the phpinfo(); command and can't find anything to do with MYSQL in the settings of the version. So i tried to download the php_mysql.dll and libmysql.dll files, I have referenced them in the php.ini file by using extension_dir="./" extension=php_mysql.dll extension=libmysql.dll (Also best to mention that " extension_dir="./" " was the only line of text in the php.ini file by default) This didn't seem to make a difference at all, still get the same error. Is there anything I can try to do? I really can't understand it as php 5 comes with mysql built in, but it seems that Sellerdeck have stripped that usability from the php version! Any advice appreciated
  2. Hello everyone: I'm having trouble with code that compares a Form value ($uname) to Field values (username) from my database. In testing, I'm using the same Form data over and over, and I now have several identical records instead of just one unique record for this user. if (empty($_POST["uname"])) { $unameErr = "* Username is required"; } else { $uname = test_input($_POST["uname"]); if (!preg_match("/^[a-zA-Z0-9]*$/",$uname)) { $unameErr = "* Only letters and numerals are allowed"; } else { // Now sure the username is legit, we check to see if it's a // unique username by comparing it to all usernames already in member table. require_once 'login.php'; // This file contains database access credentials $db_conn = new mysqli($db_hostname, $db_username, $db_password, 'login'); if($db_conn->connect_error) die ('Connect Error: ('.$db_conn->connect_errno.')'.$db_conn->connect_error); $query = "select username from member"; // Only selecting the field to compare to $result = $db_conn->query($query); if(!$result) die ('Database access failed: ('.$db_conn->connect_errno.')'.$db_conn->connect_error); $rows = $result->num_rows; for($i = 0; $i <= $rows; $i++) { if(mysqli_fetch_assoc($result) == $uname) { $unameErr = "* Username already in use. Please choose another."; mysql_close($db_conn); exit; } } $query = "insert into member values(NULL, '$uname', '$pwd1', '$fname', '$lname')"; $result = $db_conn->query($query); if(!$result) die ("Database insertion failed: ".mysql_error()); } } This is my first attempt at this using PHP and am pleased that I can at least access my db. But I just can't figure out how to make this comparison check. Thanks in advance for any help you offer. ~Landslyde
  3. Hi guys I would like to get whole content of html file after I submitted a password. The problem is that the my code doesn't access the value for the file. I tried to create a session but i doesn't work. What other option do I have to get the content of the html file? session_start(); $selected_file = $_POST['radio1']; // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; $password = 'code'; $lines = file("$filename.html"); $_SESSION['selectedfile'] = $selected_file; $_SESSION['file'] = $filename; $_SESSION['Scipt'] = ("$filename.html"); $_SESSION['Scipttext'] = $lines; $_SESSION['file2'] = $fileinfo; if (isset($_POST['submitradio'])) { echo '<div class="imageselected">'; echo '<img src="'.$_SESSION['selectedfile'].'" /></br>'.PHP_EOL; echo '</div>'; // check to see if a html file named the same also exists if(file_exists($_SESSION['Scipt'])) { echo "<form action='test_result.php' method='post'>"; echo '<div class="Password">'; echo 'Type in password to view full Script'; echo "<label><div class=\"Input\"><input type='password' name='passIT' value='passit'/></div>"; echo "<input type='submit' name='submitPasswordIT' value='Submit Password'/></div>"; echo '</div>'; echo "$filename.html shares the same name as $selected_file"; for($x = 1;$x<=15;$x++) { header( "Content-Type: file/html" ); $lines = ($_SESSION['Scipttext']); $new = strip_tags($lines); echo $lines[rand(0, count($lines)-1)]."<br>"; } // end of forloop } // end of check // start Sorrytext else { echo '<div class="NoScript">'; echo "Nothing available at the moment."; echo '</div>'; } // end Sorrytext } // End of submitradio if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ echo "You entered correct password"; readfile($_SESSION['Scipt']); } else{ echo "You entered wrong password"; } } echo '</form>'; I would be grateful for help.
  4. Hi we had some software develops that needs to bulk upload from a mailbox. When we are setting up a Cron job within the Plesk control panel on the dedicated server our developer is getting the follow error and not sure of a solution? - Can anyone advise please - Thank you! Getting the following message when I run the cron: PHP Warning: imap_open(): Couldn't open stream {localhost} in /var/www/vhosts/cvdatabase.management/httpdocs/send_email.php on line 116 PHP Warning: imap_num_msg() expects parameter 1 to be resource, boolean given in /var/www/vhosts/cvdatabase.management/httpdocs/send_email.php on line 151 PHP Notice: Unknown: Certificate failure for localhost: self signed certificate: /C=US/ST=Virginia/L=Herndon/O=Parallels/OU=Parallels Panel/CN=Parallels Panel/emailAddress=info@parallels.com (errflg=2) in Unknown on line 0
  5. Hello, we got a site running in to different servers, the other one is a sub domain that will be use as internal pages and the other one is external. As of that I need to pass session to see if a user details. Is there a another secure way to pass session data to other server without storing on the database?
  6. I am new here I dont know if I am breaching any policy by posting questions. Are there any Tutorials that can give me input for wordpress basics such as listed here - http://codex.wordpress.org/Plugin_API http://codex.wordpress.org/Class_Reference I would be indebted if you can help me with that. Looking Forward. Cheers!
  7. After 13 years of laboring over this, I finally got my form fixed today. Just two issues left: 1) Upon form submission, an email is sent out to the user. How do I redirect them to a Thank-You page so they don't have to stare at the Registration screen while the email is being sent out, as this seems to be a little slow. 2) In the body of these emails is a link to click to go to the Login screen. This works fine. However, I also provide them with two email addresses. How do I make them clickable (like the web link)? $message = $fname.":\n\n"."Thank you for subscribing to my services.\n\nYour login credentials are:\n\nUsername: ".$uname."\nPassword: ".$pwd1."\n\nPlease click the link below to proceed to Login screen:\n\nwww.mySite.com/login.php\n\n\n\nTech Support: techsupport@mysite.com\nSales: sales@mysite.com"; Thanks for your help, Landslyde PS: Just kidding abt the 13 years...only took 12
  8. Hi I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems. 1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that? for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; } I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } } If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; You may need this lines to: $selected_file = $_POST['radio1']; // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; Help would be very much appreciated.
  9. I have a php page which is ran after a form is posted from the previous page. I am having trouble getting the SQL strings to work. When the page is ran online there is no WSOD or error message but the tables in my database are not being updated. Any help with this would be greatly appreciated. payment.php
  10. how i can make a insert using this fuctions I m learning php, as using this functions (mysqli abstract) but after update wont work any more. /** insert data array */ public function insert(array $arr) { if ($arr) { $q = $this->make_insert_query($arr); $return = $this->modifying_query($q); $this->autoreset(); return $return; } else { $this->autoreset(); return false; } } complement /** insert query constructor */ protected function make_insert_query($data) { $this->get_table_info(); $this->set_field_types(); if (!is_array(reset($data))) { $data = array($data); } $keys = array(); $values = array(); $keys_set = false; foreach ($data as $data_key => $data_item) { $values[$data_key] = array(); $fdata = $this->parse_field_names($data); foreach ($fdata as $key => $val) { if (!$keys_set) { if (isset($this->field_type[$key])) { $keys[] = '`' . $val['table'] . '`.`' . $val['field'] . '`'; } else { $keys[] = '`' . $val['field'] . '`'; } } $values[$data_key][] = $this->escape($val['value'], $this->is_noquotes($key), $this->field_type($key), $this->is_null($key), $this->is_bit($key)); } $keys_set = true; $values[$data_key] = '(' . implode(',', $values[$data_key]) . ')'; } $ignore = $this->ignore ? ' IGNORE' : ''; $delayed = $this->delayed ? ' DELAYED' : ''; $query = 'INSERT' . $ignore . $delayed . ' INTO `' . $this->table . '` (' . implode(',', $keys) . ') VALUES ' . implode(',', $values); return $query; } before update this class i used to insert data like this $db = Sdba::table('users'); $data = array('name'=>'adam'); $db->insert($data); this method of insert dont works on new class. if i try like this i got empty columns and empty values. thanks for any help complete class download http://goo.gl/GK3s4E
  11. Hi I want to echo out something when I post the value of a radio button and this value matches the same name of a html file. How can I formulate my code to achieve that? What I have so far: <?php if (isset($_POST['submitradio'])) { $selected_dir = $_POST['radio1']; echo substr($selected_dir, 0, -4); echo '<img src="'.$selected_dir.'" />'; } ?> So far I get for example the name of the image(order.gif) and the image order. gif. What I now want is to formulate my code so that I can say if I have an image called "order.gif" and a file called "order.html" that I can then echo out some thing. I don't want to actually name the image or the html file. I just want to say if I have two different file types that start with the same name then I can echo out what ever. How can I do that?
  12. Hello yes so I let myself be carried away, and then came a new small challenge. In the graph code is the csv file opened and soteret with a "explod" function. and it work fine as long as I only have one column with y data and one with x data. but when I start to get more column's it does not work. I've created a short example below. <?php define("LOG_FILE", "./data/test111/test111-2015-01-17.csv"); $times = array(); $values = array(); $values_test1 = array(); $file_lines = file(LOG_FILE , FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); foreach($file_lines as $line_num => $line_value) { $line_elements = explode(",", $line_value); $times[] = date($line_elements[0]); $values[] = $line_elements[1]; $values_test1[] = $line_elements[2]; } echo $values[2]; ?> the control echo I make "echo $values[2];" works fine, there is be the expected value. but if I try to "echo $values_test1[2];" so there is nothing. the CSV file looks like this. Date,temp1,temp2 2015-01-23-12-00,54,59 2015-01-23-12-01,54,59 2015-01-23-12-02,54,59 2015-01-23-12-03,54,58 2015-01-23-12-04,54,58 2015-01-23-12-05,54,58 2015-01-23-12-06,54,58 2015-01-23-12-07,54,58 2015-01-23-12-08,54,58 2015-01-23-12-09,54,58 2015-01-23-12-10,54,58 2015-01-23-12-11,53,58 2015-01-23-12-12,53,58 2015-01-23-12-13,53,58 2015-01-23-12-14,53,58 why can I not get the temp2 values into $ values_test1 [] thank you very much
  13. Hi I echo out images from a folder. The problem is that I have a html file in the same folder but I don't want to echo that out. How can I write my code to get rid of the html in the output? Here my code: <?php $filetype = '*.html'; $dirname = substr('$filetype'); $i=0; if (isset($_POST['submit2'])) { //get the dir from POST $selected_dir = $_POST['myDirs']; //now get the files from within the selected dir and echo them to the screen foreach(glob($selected_dir . DIRECTORY_SEPARATOR . '*') as $dirname) { echo substr($dirname, 0, -4); echo '<img src="'.$dirname.'" />'; echo "<label><div class=\"radiobt\"><input type='radio' name='radio1' value='$i'/></div></label>"; } } ?> P.S. when I echo out : substr($dirname, 0, -4); I want to get ride of the html filename there too. How can I do so something like this?
  14. include "header.php"; if(isset($_GET['post_id'])) { $select=mysqli_query($con,"select...."); while($data=mysqli_fetch_array($select)) { echo "bla bla bla"; to_head("<title>asd</title><meta itemprop="name" content="asdfasdf">..."); } } include "footer.php"; This is samthing what i want... I have header.php and footer.php and any script ex news.php where how news and read SEO stuff from database and put in HEAD of the document. I tried with jquery like $("head").append(str); and it works but then i read google don't run jquery when vist website. This is done with drupal, wordpress and php-fusion Drupal: https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_html_head/7 php-fusion: https://www.php-fusion.co.uk/forum/viewthread.php?thread_id=30959 so it is possible but i don't know how. Any idea?
  15. Alright I am so close but can not figure this out, thanks in advance for any help. So what I am trying to do is take the input variables from a form and have them load a specific PDF . <html> <body> <?php if( $_GET["startpoint"] || $_GET["endpoint"]) { $a = $_GET["startpoint"]; $b = $_GET["endpoint"]; echo "Your Startpoint is:". $_GET["startpoint"]. "<br />"; echo "Your Endpoint is: ". $_GET["endpoint"]. "<br />"; echo $a,$b,".pdf"; } ?> </body> </html> This is what I have and it works to display what the two points are what the final pdf file should be. The final echo generates the PDF name echo $a,$b,".pdf"; How can I get it to load a file using this as a variable or the name it generates, thanks.
  16. Hi; I'm a beginner and I'm getting a big headache figuring how to convert php variables into Javascript variables. I want to use the content of $theName as the value for an input tag. $_SESSION['$Sess_Name'] is loaded with the right data, I verified it. But my function InitField returns always the word NULL. Why is that? Where is the problem? Thank Here is my code: function InitField() { <?php $theName = $_SESSION['$Sess_Name']; ?> var tempoVar = "<?php echo json_encode($theName); ?>"; var myInput = document.getElementById('theSurname'); myInput.value = tempoVar; }
  17. I understand that is might be something that is already answered and I apologize if it is, I could not find it. What I need to do is build a simple form that has two options, they will be dropdown options. Dropdown A and Dropdown B then a Submit button. This part I understand in HTML, although it may be easier in php or javascript. Then I need it to take the two options and create a "if/then" statement that loads a specific pdf that matches the two options selected. Example. If someone selects Option 1 from Dropdown A and Option 2 From Dropdown B then it loads 12.pdf If someone selects Option 5 from Dropdown A and Option 3 From Dropdown B then it loads 53.pdf If someone selects Option 2 from Dropdown A and Option 1 From Dropdown B then it loads 21.pdf and so on... It does not have to be the exact thing just some way to take both inputs and have it equal a specific pdf. Here is the form I built but I don't know what to put in the form_action.php file in order to make it work <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <center> <h1> Get Directions</h1> <form action="form_action.php" method="get" name="directions" target="_new"> <select name="startpoint" size="1"> <option value="north">North Tower Entrance</option> <option value="south">South Tower Entrance</option> <option value="moba">MOB A Entrance</option></select> -----> <select name="endpoint" size="1"> <option value="onco">Oncology</option> <option value="radio">Radiology</option> <option value="pulm">Pulmanary</option></select> <br /><br /> <input type="submit" value="Submit" /> </form> </center> </body> </html> Any help is appreciated, thanks.
  18. I have the week date range displaying the week range from sunday - saturday $current_dayname = date("0"); // return sunday monday tuesday etc. echo $date = date("Y-m-d",strtotime('last sunday')).'to'.date("Y-m-d",strtotime("next saturday")); Which outputs in the following format 2015-01-25to2015-01-31 However, when I press next or previous, the dates don't change. <?php $year = (isset($_GET['year'])) ? $_GET['year'] : date("Y"); $week = (isset($_GET['week'])) ? $_GET['week'] : date('W'); if($week > 52) { $year++; $week = 1; } elseif($week < 1) { $year--; $week = 52; } ?> <a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week == 52 ? 1 : 1 + $week).'&year='.($week == 52 ? 1 + $year : $year); ?>">Next Week</a> <!--Next week--> <a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week == 1 ? 52 : $week -1).'&year='.($week == 1 ? $year - 1 : $year); ?>">Pre Week</a> <!--Previous week--> <table border="1px"> <tr> <td>user</td> <?php if($week < 10) { $week = '0'. $week; } for($day= 1; $day <= 7; $day++) { $d = strtotime($year ."W". $week . $day); echo "<td>". date('l', $d) ."<br>". date('d M', $d) ."</td>"; } ?> </tr> </table>
  19. Our website now is using Proxy we would like to get the Visitory IP. We try to get using HTTP_X_FORWARDED_FORbut it seems that doesn't get the IP. Were running the site on IIS.
  20. Hi Yes I start a new thread, this is probably the correct one. I have solved my problem almost. the result ends with the end of a parenthesis. see picture how do I get it deleted. <?php $dir = './data/test111'; $ddArray1 = scandir($dir,1); ?> <html> <head> <title>Select Drop Down List</title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="file"> <?php FOREACH($ddArray1 AS $file){ PRINT '<option value="'.$file.'">'.$file.'</option>'; } ?> </select> <input type="submit"/> </form> </body> </html> <?php if ($_POST) { echo '<pre&gt'; print_r($_POST); $test='</pre&gt>'; echo $test; } ?>
  21. So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html? here is the link with code&demo iamusing: http://www.sanwebe.com/2013/06/extract-url-content-like-facebook-with-php-and-jquery thanks in advance.
  22. If i check more than one checkbox. I dont get any value from database. HTML <form method="post"> <input type="checkbox" name="receiver[]" value="cheater">CHEATER <input type="checkbox" name="receiver[]" value="un-verified">UN-VERIFIED <input type="checkbox" name="receiver[]" value="inactive">INACTIVE <input type="checkbox" name="receiver[]" value="active">ACTIVE <input type="submit" name="submit" value="ADD"> </form> PHP $errors = array(); $success = NULL; $error = NULL; $var['receiver'] = isset($_POST['receiver']) ? $_POST['receiver'] : NULL; ................. if(!empty($_POST['submit'])){ // FORM VALIDATION // } if(!empty($_POST['submit']) and empty($errors)){ $status = array_map('strval', $var['receiver']) + array(0); $statusSql = implode(',', $status); $query = 'SELECT email FROM users WHERE status IN("'.$statusSql.'")'; $select = $db->prepare($query); $select->execute(); $arrayData = array(); while($row = $select->fetch(PDO::FETCH_ASSOC)){ $arrayData[] = $row['email']; } $errors[] = implode(',', $arrayData); } require_once 'includes/antiCsrf/index.php'; $csrf = new antiCsrf(); $smarty->assign('success', $success); $smarty->assign('error', $error); $smarty->assign('errors', $errors); $smarty->assign('csrfKey', $csrf->csrfKey()); $smarty->assign('csrfToken', $csrf->csrfToken()); $smarty->assign('var', $var); .................
  23. Hi, I'm trying to submit a form to itself and then have go on to another page. I've tried a few things but the form only returns to itself. How can I redirect the form after posting to itself. My HTML code is between <?php ?> tags. <head> <title>untitled</title> <script src="respond.min.js"></script> </head> <body> <form id= "formId" action="goToUrl.com" method ="post"> Name: <input type = "text" name ="firstName" value=""/> <input id="formButton" onClick="self.location='www.msn.com'" type="submit" name="submit" value="Submit" /> <br/> </form> </div> </body> </html> also tried puting this script just after the closing form tag: <script type="text/javascript"> $('#formButton').click(function(){ location="www.google.com" }); </script> In both cases the form seems to ignore the script. Thanks for any help with this!
  24. Hi all. i am trying to use php to include a javascript onto different pages, and then "sort of " pass it a var. The bulk of the code will be in an included footer php file. The var will be set in the main page. i have it working as follows: by just using echo 3 times.. the 1st with the first part of the script, the 2nd is the variable, and the 3rd is the rest of the script. The same endcode.php file needs to also be used for pages that wont have a var set, and wont be using the script - hense the isset. <!-- mainPage.php --> <?php $sion_gallery_id = '450'; ?> <?php include(endcode.php); ?> <!-- endcode.php --> <?php if (isset($sion_gallery_id)) {echo "start of javascript.......album/"; echo $sion_gallery_id; echo"/end of script"; } else { echo "var not on set";} ?> This works great, and i can set $sion_gallery_id do different numbers, and it pulls different albums through for diff pages. Is this secure enough as it is? I have read about whitelists, and tried the following: <!-- Headcode.php --> <?php $whitelist = array('465','6', '7','745','450'); ?> <!-- mainPage.php --> <?php include(Headcode.php);?> <?php $sion_gallery_id = '450'; ?> <?phpinclude(endCode.php); ?> <!-- endCode.php --> <?php if (isset($sion_gallery_id)) {if (in_array($sion_gallery_id, $whitelist)) {echo "java script content goes here.......album/"; echo $sion_gallery_id; echo"/end of script"; } else { echo "var not on white list";}} else { echo "No var set"; }; ?> This works when i try it at a basic level. However, when i set it up properly with the headcode and endcode pages being included, and also with all the actual javascript being echoed in endcode.php -- it worked perfectly for the first page. But when i changed the var to a different number, remembering to add this to the whitelist, it wont load - and echoes "var not on white list". ..... but it is? So, do i need to use a white list for this, or have i got the wrong end of the stick anyway. And if i do, can anyone see what may be happening? Is the first var getting cashed somewhere? Any help is much appreciated. Thanks, Sion.
  25. Hi I'm currently having a problem with my form. Users submit an empty field into the database and the next time another user tries to enter it just says username has been taken. I need some help on how to confirm that the username and email field isnt empty when inserted and that the email address is in the correct format. <?php include "base.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System (Tom Cameron for NetTuts)</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="main"> <?php $username = mysql_real_escape_string($_POST["username"]); $email = mysql_real_escape_string($_POST["email"]); $mxitid = mysql_real_escape_string($_SERVER["HTTP_X_MXIT_USERID_R"]); if(!isset($mxitid)) { $mxitid = "DEFAULT"; } $checkusername = mysql_query("SELECT * FROM Users WHERE mxitid = '".$mxitid."'"); $checkemail = mysql_query("SELECT * FROM Users WHERE email = '".$email."'"); if(mysql_num_rows($checkusername) == 1) { echo "<h1>Error</h1>"; echo "<p>Sorry, that username is taken. Please go <a href=\"register.php\">back</a>and try again.</p>"; } elseif(mysql_num_rows($checkemail) == 1) { echo "<h1>Error</h1>"; echo "<p>Sorry, that email is taken. Please go <a href=\"register.php\">back</a>and try again.</p>"; } elseif ($_POST["register"]) { $username = mysql_real_escape_string($_POST["username"]); if(!isset($mxitid)) $mxitid = mysql_real_escape_string($_SERVER["HTTP_X_MXIT_USERID_R"]); if(!isset($mxitid)) { $mxitid = "DEFAULT"; } $registerquery = mysql_query("INSERT INTO Users (Username,mxitid,email) VALUES('".$username."','".$mxitid."','".$email."')"); if($registerquery) { echo "<h1>Success</h1>"; echo "<p>Your account was successfully created. Please <a href=\"index9.php\">click here to start chatting</a>.</p>"; } } else { ?> <h1>Register</h1> <p>Please enter your details below to register.</p> <p>Keep it clean! or you might get banned!</p> <form method="post" action="register.php" name="registerform" id="registerform"> <fieldset> <label for="username">Username:<br> Using emoticons in your name won't work!</label><input type="text" name="username" id="username" /><br /> <label for="email">Email:<br>(We need your real one to be able to contact you!)<br> If you don't have one make use of your mxit email service.</label><input type="email" name="email" id="email" /><br /> <input type="hidden" name="mxitid" id="mxitid" value="<? $_SERVER['HTTP_X_MXIT_USERID_R']; ?>"/><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form> <?php } ?> </div> </body> </html> I tried using function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { die($problem); } return $data; } but it didnt seems to work
×
×
  • 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.