Gibbs
Members-
Posts
63 -
Joined
-
Last visited
Never
Everything posted by Gibbs
-
[quote author=jesirose link=topic=123517.msg510584#msg510584 date=1169481244] try adding trim($name) and then checking the strlen($name) > 0 [/quote] trim prints correctly. Strlen outputs 14 (which is correct). @RedArrow That does nothing for me (I even addressed a typo :P) Thanks for the replies so far by the way
-
[quote author=jesirose link=topic=123517.msg510578#msg510578 date=1169480806] Try $_POST['name']; [/quote] I have $name = $_POST['name']; and my form set to post. On the page i've printed all the vars and they come out fine I just didn't want to spam the page with echoed HTML :P
-
I don't want to use javascript and every PHP form validation scripts i've taken a peak at look very complicated for such an easy task. All I want to do is check the the fields are filled in. It doesn't bother me about the lengths etc. I'm running into problems with what I've done below. [code=php:0]if ($perform == check) { $errorcheck = FALSE; echo "<br><br>"; if (empty($name)) { $errorcheck = TRUE; } else { $errorcheck = FALSE; } if ($errorcheck = TRUE) { echo "<p class=\"error\"><b>An error occured. Please check below.</b></p>"; } else { echo "<p>Please make sure the details are correct.</p>"; } [/code] That's the top of my code. I've tried quite a few variations including an ifelse(!empty($var)) and HTTP_POST_VARS as well as if $var == "" etc. The problem is $errorcheck always comes back as 1 even if $name isn't empty. Hell I had $errorcheck return as 0 and it still printed the error message. Sorry if im babbling im getting a headache over this and need to move on to more pressing matters. Thanks for any help.
-
I noticed that if I get "Name" from a MySQL database the results are different to getting "name". Is it possible to counter this without having to change "Name" or "name" in PHP?
-
Grrr. It's always something stupidly easy I get headaches over. Thanks for the help! That print_r($_POST); is very useful, will be using it a lot in the future. Thanks again everything is working :)
-
Sorry still new to this. [quote]Array ( [bio_fname] => Name [bio_sname] => Name [bio_age] => 32 [bio_gender] => Male [bio_birth] => London [bio_residence] => Devon [bio_bio] => TEST [bio_education] => TEST [bio_training] => TEST [Submit] => Submit Entry )[/quote] Looks like that worked... What can I do with this info, or what does it indicate?
-
[quote author=jesirose link=topic=123041.msg508204#msg508204 date=1169162128] add this ?><pre><? print_r($_POST); ?></pre><? before here: $firstname = $_POST['bio_fname']; And tell me what it prints. [/quote] It prints "Array ( )" Edit: I'm using a lot of includes on this page. Could they be conflicting (although everything else is working...)?
-
$perform==submit1337 etc work. These are being returned as the number 1 after submitting the form... [code]$firstname = $_POST[bio_fname]; $secondname = $_POST['bio_sname']; $age = $_POST['bio_age']; $gender = $_POST['bio_gender']; $birth = $_POST['bio_birth']; $residence = $_POST['bio_residence']; $bio = $_POST['bio_bio']; $education = $_POST['bio_education']; $training = $_POST['bio_training'];[/code]
-
I'm really confused. To test that i'm getting the right information from the forms i've printed them... Any help would be great! This is how i'm getting the info: [code=php:0]include("include/session.php"); $userx = $session->username; // Get the username logged in $perform = $_GET['perform']; // Get the perform URL $table = "bio"; // The table to read and write to // Get the employee details (if they submit them) $firstname = $_POST[bio_fname]; $secondname = $_POST['bio_sname']; $age = $_POST['bio_age']; $gender = $_POST['bio_gender']; $birth = $_POST['bio_birth']; $residence = $_POST['bio_residence']; $bio = $_POST['bio_bio']; $education = $_POST['bio_education']; $training = $_POST['bio_training'];[/code] This is the form etc... [code=php:0]if ($perform==add) { echo "<p>Welcome $userx. Please submit accurate and correct information only. If you make any mistakes or your details change you may update your entry at any time. <br>Thank you.<br></p> <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <form action=\"vtxemp.php?perform=submit1337\" method=\"post\"> <tr> <td width=\"115\" height=\"25\"><p align=\"right\">First name: </p></td> <td width=\"385\"> <input name=\"bio_fname\" type=\"text\" class=\"textpm\"></td> </tr> <tr> <td height=\"25\"><p align=\"right\">Second Name: </p></td> <td><input name=\"bio_sname\" type=\"text\" class=\"textpm\"></td> </tr> <tr> <td height=\"25\"><p align=\"right\">Age: </p></td> <td><input name=\"bio_age\" type=\"text\" class=\"textpm\" size=\"2\" maxlength=\"2\"></td> </tr> <tr> <td height=\"25\"><p align=\"right\">Gender: </p></td> <td> <select name=\"bio_gender\" class=\"dropdownl\"> <option value=\"Male\">Male</option> <option value=\"Female\">Female</option> </select></td> </tr> <tr> <td height=\"25\"><p align=\"right\">Place of Birth: </p></td> <td><input name=\"bio_birth\" type=\"text\" class=\"textpm\"></td> </tr> <tr> <td height=\"25\"><p align=\"right\">Current Residence: </p></td> <td><input name=\"bio_residence\" type=\"text\" class=\"textpm\"></td> </tr> <tr> <td valign=\"top\"><p align=\"right\">Employee Bio: </p></td> <td><label> <textarea name=\"bio_bio\" cols=\"60\" rows=\"10\" class=\"textpm\"></textarea> </label></td> </tr> <tr> <td valign=\"top\"><p align=\"right\">Education: </p></td> <td><textarea name=\"bio_education\" cols=\"60\" rows=\"4\" class=\"textpm\"></textarea></td> </tr> <tr> <td valign=\"top\"><p align=\"right\">Training: </p></td> <td><textarea name=\"bio_training\" cols=\"60\" rows=\"4\" class=\"textpm\"></textarea></td> </tr> <tr> <td valign=\"top\"> </td> <td><label> <input type=\"submit\" name=\"Submit\" value=\"Submit Entry\"> </label></td> </tr> </form> </table>"; } if ($perform==submit1337) { echo $firstname or die("First name not entered"); echo $secondname or die("Second name not entered"); echo $age or die("Age not entered"); echo $gender or die("Gender not entered"); echo $birth or die("Place of Birth not entered"); echo $residence or die("Current Residence"); echo $bio or die("Employee Biography not entered"); echo $education or die("Education details not entered"); echo $training or die("Training details not entered"); //$create = "INSERT INTO $table (firstName, secondName, age, gender, placeBirth, cResidence, bio, education, training, username) //VALUES ('$firstname','$secondname','$age','$gender','$birth','$residence', '$bio', '$education', '$training')"; //$create2 = mysql_query($create) or die("Database Entry Failed"); //echo("<br><br>Thank you. Your details have been submitted to the Vortex Network Employee Database"); }[/code] I'm so confused as to whats going wrong.... Please help! Thank you :)
-
I've just been having a play around to see where you might have gone wrong. First of all when I try to create a database called "employee index" it created a database called "employee". Edit your database so that you are using underscores _ instead of spaces. So change "employee index" to "employee_index" and "employee details" to "employee_details". Then edit the PHP accordingly. Worth a try.
-
Change "INSERT INTO $employee details" to "INSERT INTO $employee"
-
So simple! I can't believe that ::) Thanks for your help! :P
-
Strange. $employee = "employee details"; $sqlquery = "INSERT INTO $employee blah blah blah SHOULD work. Are your user, host and password correct? What's the error?
-
It's all done in the same page. I'm getting action using [code=php:0]<?php $action = $_GET['action'];[/code]
-
Sorry yes I wasn't right. What's the name of the table your trying to put the information into? If you know the name above $sqlquery try this: $employee = "my table name". The start should then look like this: [code=php:0]<?php $user="root"; $host="localhost"; $password=""; $database = "employee index"; mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("employee index") or die(mysql_error()); $employee = "My table name" // Change this $sqlquery = "INSERT INTO $employee (Employee_ID,Surname,Forename,Job_title,Office_location,Telephone,Email,Expertise,Hobbies,DOB) VALUES ('$Employee_ID','$Surname','$Forename','$Job_title','$Office_location','$Telephone','$Email','$Expertise','$Hobbies','$DOB')"; [/code] Edit: Don't use spaces in variables/strings. $employee details won't work. Use $employee_details.
-
I'm still confused. I've tried this (i'll post the entire part as it may make more sense). [code=php:0]$result=mysql_query("select * from $table where UserTo='$cookie' ORDER BY SentDate DESC") or die ("ERROR: PLEASE REPORT THIS"); echo "<table cellpadding=2 cellspacing=1 width=400 valign=top>"; $row = mysql_fetch_array($result); $messageid = $row[mail_id]; // mail_id while ($row=mysql_fetch_array($result)) { echo "<tr><td width=30><p>Mail:</td><td><a href=pm.php?action=view&mail_id=$row[mail_id]> $row[Subject] </a></td><td width=50> <a href=pm.php?action=delete&id=$row[mail_id]> <center>Delete </a><br></td></tr>"; } echo "</table>"; } if($action==view) { $result = mysql_query("select * from $table where UserTo='$cookie' and mail_id='$messageid'") or die ("cant do it1"); $row = mysql_fetch_array($result); if($row[UserTo]==$cookie) { } else { echo "<p class=\"error\"><b>This isn't your mail!</b></p>" .$row; exit;[/code]
-
I have a basic Private Message system working on my site. However i'm having problems with PHP getting the mail_id information from MySQL. If I do this I can get the mail ID: [code]$result=mysql_query("select * from $table where UserTo='$cookie' ORDER BY SentDate DESC") or die ("ERROR: PLEASE REPORT THIS"); while ($row=mysql_fetch_array($result)) { echo $row[mail_id]; [/code] However i'm trying to get the mail_id in a different part and am finding it difficult. When somebody selects a link this is used: [code]$result =mysql_query("select * from $table where UserTo='$cookie' and mail_id='[mail_id]'") or die ("cant do it1"); //echo mysql_num_rows($result); $row = mysql_fetch_array($result); if($row[UserTo]==$cookie) [/code] However the mail_id isn't recognised like previously. Is there a way to use the code at the top to get the mail_id to work here? Any help appreciated. Thanks
-
Im new too so don't expect too much ;D What i'm trying to say is that you have "INSERT INTO $employee". This means INSERT INTO $MYTABLE. You don't have $employee set to anything though. So it's trying to INSERT INTO (nothing). Try changing $employee with $database (which you have set to "employee index")
-
Try echo $employee (to see if anything is printed). It doesn't look like you've set $employee to anything (which is the table your trying to write to). If true your trying to write to a table with no name.
-
Actually I do have a problem with this (dont want to create another thread). I need to read only rows that have "status" set to unread. I've tried this but it doesn't work.... [code]SELECT COUNT(status='unread') FROM $tblnamer AS TOTAL WHERE UserTo='$justr' ORDER BY SentDate[/code] Ah figured it out. SORRY! :P
-
The edit buttons gone again :o I figured it out. Thanks for your much needed help! :)
-
[code]$get_mail = mysql_query("SELECT COUNT('status') FROM $tblnamer AS TOTAL WHERE UserTo='$justr' ORDER BY SentDate") or die ("<br><br>Can't execute $sql: " .mysql_error());[/code] This works (thanks to your help). When I run it through PHPMyAdmin is gives me the number 2. When I run $inboxcount = mysql_num_rows($get_mail); through PHP I get the number 1. Number 2 is correct. How can I get that number into a PHP string? Thanks by the way :)
-
Hello, I have a database named "mail" which has 5 different fields. These are the fields: UserTo, UserFrom, Subject, Message, status, SentDate and mail_id. What I want to do is get the total number of rows that have status set to "unread" in them for a certain username. I would like to have a variable with a number so users know how many unread mails they have. Any help would be great. Thanks!
-
Ops double post
-
Ah thanks. The reason was that the <br/> tags got added, as told to, but on opening the file it added new ones as the old ones were only being displayed. Difficult to explain. Your replies helped a lot though. Thank you jesirose and obsidian ;D