Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Everything posted by joel24

  1. What about strings such as "1.0"? he'd have to search for a fullstop followed by a space, or a new line?
  2. the autocrit site you linked to was created using php. you'd just have to play around with some string functions http://us2.php.net/strings
  3. if i were doing it i'd have an error table in my database (+ there will now be an audit trail of errors/messages displayed) i'd have that table set up like id username dateTimeStart dateTimeEnd error usersViewed then i'd have a javascript function which posted to a php page every five minutes using the setTimeout("checkErrors()",30000); and if that page returned anything it would make a div pop up and display the error message... then the php page would using mysql and the user's ID and check if there are any errors where currentdateTime > startDateTime and less than dateTimeEnd then i'd have all the userID's of people who had seen the error message in the usersViewed seperated by commas i'd pull that and use PHP to explode(",", $errorDetails['users']) so that they were in an array then i'd use the in_array function to see if the user had viewed the error if not, i'd make the php echo the error message and the javascript function checkErrors would register this and popup teh error div and display the error message... the php function would also have to add the usersID to the usersViewed column. make sense?
  4. are you doing that just so the id's don't start at 1? i.e. they start at say 10000? if so you can use id INT NOT NULL AUTO_INCREMENT = 10000, on your table which will make the auto increment start at 10000? otherwise you'd have to get a php script which looks at the last inserted value... and adds one to that?
  5. you should let MySQL generate the id's... set the ID column to be primary key & auto_increment id INT NOT NULL AUTO_INCREMENT,
  6. change it to if (is_numeric($userrank) && $userrank == 0)
  7. don't entirely understand what you want?
  8. function ZeroFill($number) { if (strlen($number) == 1) { $number = "00".$number; } elseif (strlen($number) == 2) { $number = "0".$number; } return $number; }
  9. $i++ means that the variable $i will increment by one each time the loop or script reaches it... the line <input type="radio" name="chk_accept<?php echo $i++; ?>[]" value=1> alone would just echo the value of $i + 1 once. i.e. say $i is equal to 1 it would only echo the following line. <input type="radio" name="chk_accept2[]" value=1> you need a loop to echo it multiple times... like the for loop or while loop i showed u
  10. wooops. that will just put in the image src="images/parts/" if the database image field is empty. use this.. <?php if (!empty($row_rs_radiators['image2'])) { echo '<a href="images/parts/'.$row_rs_radiators['image2'].'" target="_blank">'; echo '<img src="images/parts/'.$row_rs_radiators['image2'].'" alt="'.$row_rs_radiators['title'].'" width="200" /></a>'; } ?>
  11. going from your original post... <a href="images/parts/<?php if (!empty($row_rs_radiators['image2'])) { echo $row_rs_radiators['image2']; } ?>" target="_blank"> <img src="images/parts/<?php if (!empty($row_rs_radiators['image2'])) { echo $row_rs_radiators['image2']; } ?>" alt="<?php echo $row_rs_radiators['title']; ?>" width="200" /></a>
  12. $rowCount = mysql_num_rows($rst_adjusters); for ($i = 0; $i <= $rowCount; $i++) { echo '<input type="radio" name="chk_accept{$i}[]" value=1>\n'; echo '<input type="radio" name="chk_accept{$i}[]" value=0>\n'; } will do it, however, you're better off changing your mysql query, so the MySQL db counts... change it to something like $rst_adjusters=@mysql_query("SELECT count(*) FROM tableName WHERE x = y"); and then have $rowCount = mysql_fetch_row($total); $rowCount = $rowCount[0]; for ($i = 0; $i <= $rowCount; $i++) { echo '<input type="radio" name="chk_accept{$i}[]" value=1>\n'; echo '<input type="radio" name="chk_accept{$i}[]" value=0>\n'; }
  13. <?php if (!empty($row_rs_radiators['image2'])) { echo 'images/parts'.$row_rs_radiators['image2']; } ?>
  14. are you actually pulling any data from the database with your the sql command.. the $rst_adjusters one? or just counting how many rows?? anyway, the code you had would add $i to the end of the input tag... well fater teh chk_accept thingo however many times the loop exectured.. i.e. '<input type="radio" name="chk_accept[]"123456789101112value=1>... and having $i=0 at the top of the loop, $i will always equal zero, you need it before the loop. you need to echo the input statement within the loop i.e. $i = 0; while ($row = mysql_fetch_assoc($rst_adjusters)) { echo '<input type="radio" name="chk_accept{$i}[]" value=1>\n'; echo '<input type="radio" name="chk_accept{$i}[]" value=0>\n'; $i++; }
  15. <?php if (!empty($row_rs_radiators['image2'])) { echo $row_rs_radiators['image2']; } ?> just need to put a ! infront of the empty to get the opposite value...? i.e. if its not empty. also are your images stored in the database, or just a link to the image? cause if its stored in the database you're going to get php echoing a load of binary data and no image will be displayed....
  16. what do you mean dynamic? like the amount of radio groups is dependent on the number of database rows...?
  17. check to see if that sql statement is executing properly? change the $reA = mysql_query... line to the following... you'll want to change it back when you make the site live and put in some custom error handling $resA = mysql_query($sqlA) or die(mysql.error());
  18. just use the isset() function in your index file and use that to include the corresponding files... i.e. in your index, after you do all your admin checking etc, this example is for your do_add_ptype.php file. if (isset($_POST['new_ptype'])) { include ("do_add_ptype.php"); } the isset($_POST['new_ptype'])) checks if the $_POST['new_ptype'] is set, i.e. if a form containing an element with the name new_ptype has been sent... and if this is true, the if statement then includes the corresponding file so it can be executed. play around with this concept and you'll get it working? just make sure the $_POST['whatever'] has a unique identifier for each use case. this way all your forms should be posting to index.php... you might have to edit the do_add_ptype.php file a bit to make it work... and you can remove the dbconnect etc includes from the top of each file... and maybe put them in a seperate folder
  19. if that doesn't work, put in the following lines ini_set ("display_errors", "1"); error_reporting(E_ALL); at the very top of the code.. the line after <?php and try and run the program and tell me exactly what happens? does it say Thank you for sending email etc?
  20. okay, i just uploaded it on my site and it worked? i got rid of my debugging lines (i put them in the wrong spot anyway, didn't notice you had an elseif there): echo "Subject: $subject<br/> User Name: $userName<br/> Posted Message: $userMessage<br/> Email Message: $message<br/><br/> To email: $email"; exit(); this is the code as is on my server, minus the yourEmail@yourdomain.com thingo... <?php /*$_POST */ $subject = 'New message from site'; $userMessage = $_POST['message']; $userName = $_POST['userName']; $userEmail = $_POST['email']; $email = 'yourEmail@yourdomain.com'; $message = "Email sent from $userName \n Reply: $userEmail \n Message: $userMessage"; if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for sending email</h4>"; } else { echo "<h4>Can't send email to $email</h4>"; } ?>
  21. ... might be a silly question, but did you remember to change the $email = 'myemail@mywebsite.com'; line to your email in the code i posted? if you didn't, change it and try it again.. otherwise try this code and tell me what gets displayed... I've made the subject always "New message from site"... you can change this to whatever you want. <?php /*$_POST */ $subject = 'New message from site'; $userMessage = $_POST['message']; $userName = $_POST['userName']; $userEmail = $_POST['email']; $email = 'myemail@mywebsite.com'; $message = "Email sent from $userName \n Reply: $userEmail \n Message: $userMessage"; if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } echo "Subject: $subject<br/> User Name: $userName<br/> Posted Message: $userMessage<br/> Email Message: $message<br/><br/> To email: $email"; exit(); elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for sending email</h4>"; } else { echo "<h4>Can't send email to $email</h4>"; } ?> HTML <form action="send.php" method="post" enctype="application/x-www-form-urlencoded" name="contactForm" id="contactForm"> <p align="left" class="form">Your name</p> <p align="left"> <input name="userName" type="text" class="formtext" id="userName" size="40" maxlength="50" /> </p> <p align="left" class="form">Your email address </p> <p align="left" class="form"> <input name="email" type="text" class="formtext" id="email" size="40" maxlength="50" /> </p> <p align="left" class="form">Your comments or query</p> <p align="left"> <textarea name="message" cols="40" rows="10" class="formtext" id="message"></textarea> </p> <p align="left" class="form"> <input name="Submit" type="submit" class="form" id="Submit" value="Submit" /> </p> <p class="form"> </p> </form>
  22. you wrote myname in the name field nad comment in the comment field, yes? did you type anything in the subject field? *** just noticed after i typed all the stuff below this... *** an input with the name "comment" is being posted... and the comment field in your form is named "message".... is the HTML FORM you wrote the right one? is send.php in the same directory as the form HTML file? and the contents of send.php is that of the PHP code you've been posting, yeah? also, you have no "name" field in the html form... it says name but its being sent as "subject"... i fixed up the php/html for you... <form action="send.php" method="post" enctype="application/x-www-form-urlencoded" name="contactForm" id="contactForm"> <p align="left" class="form">Your name</p> <p align="left"> <input name="userName" type="text" class="formtext" id="userName" size="40" maxlength="50" /> </p> <p align="left" class="form">Your email address </p> <p align="left" class="form"> <input name="email" type="text" class="formtext" id="email" size="40" maxlength="50" /> </p> <p align="left" class="form">Subject</p> <p align="left"> <input name="subject" type="text" class="formtext" id="subject" size="40" maxlength="50" /> </p> <p align="left" class="form">Your comments or query</p> <p align="left"> <textarea name="message" cols="40" rows="10" class="formtext" id="message"></textarea> </p> <p align="left" class="form"> <input name="Submit" type="submit" class="form" id="Submit" value="Submit" /> </p> <p class="form"> </p> </form> <?php /*$_POST */ $subject = $_POST['subject']; $userMessage = $_POST['message']; $userName = $_POST['userName']; $userEmail = $_POST['email']; $email = 'myemail@mywebsite.com'; $message = "Email sent from $userName \n Reply: $userEmail \n Subject: $subject \n Message: $userMessage"; if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for sending email</h4>"; } else { echo "<h4>Can't send email to $email</h4>"; } ?>
  23. you can post the form to the page it is on, and the corresponding php if statement (if isset($_POST[ETC])) will be executed... and then put header('location: '.basename($_SERVER['PHP_SELF'])); exit(); at the end which will get the browser to reload the page without any $_GET or $_POST variables...? i.e. <?php $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { //print_r($_POST['adj']); //exit(); $i = 0; Do { $adjID = $_POST['adj'][$i]; if($adjID<>"Please Select") { $updateSQL = sprintf("UPDATE claimcue SET adj_id='" . $adjID . "' WHERE maxclaimnum=" . $row_rstassign['maxclaimnum']); mysql_select_db($database_maxdbconn, $maxdbconn); $Result1 = mysql_query($updateSQL, $maxdbconn) or die(mysql_error()); } $i++; } while ($row_rstassign = mysql_fetch_assoc($rstassign)); //get page to reload so all user POST variables etc are flushed header('location: '.basename($_SERVER['PHP_SELF'])); exit(); } ?> is that what you were after?
×
×
  • 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.