spacepoet
-
Posts
320 -
Joined
-
Last visited
Posts posted by spacepoet
-
-
Hi:
Can anyone tell me why the following is not working:
a_Photo_Delete.php <?php $photo_id = $_REQUEST['photo_id']; mysql_query("DELETE FROM gallery_photos WHERE photo_id = $photo_id"); header("Location: a_Photo_Edit.php"); ?> <!DOCTYPE HTML> <html> <head> <meta charset="ISO-8859-1" /> <title></title> </head> <body> </body> </html> ------------------------------ a_Photo_Edit.php <p> <?php if ($_REQUEST['URL'] == 'a_Photo_Delete.php') { echo "<span class=\"textError\">Photo successfully deleted!</span>"; } ?> </p>
The photo gets deleted OK, and the HEADER goes to the "a_Photo_Edit.php" page properly, but the "Photo successfully deleted!" message does not show up ..
Confused why ..
??
-
Hi:
I am having an issue with 2 brackets in the name of the FILE INPUT filed used to upload a photo.
Basically, my JavaScript form validation will not work unless they are removed, and if they are then the photo will not upload.
Anyone know a trick around this?
This is the code:
<script language="JavaScript"> function validate_form() { valid = true; if ( document.upload_form.photo_filename[].value == "" ) { alert ( "Please add a photo." ); valid = false; } return valid; } </script> <?php // initialization $photo_upload_fields = ""; $counter = 1; // default number of fields $number_of_fields = 1; // If you want more fields, then the call to this page should be like, // preupload.php?number_of_fields=20 if( $_GET['number_of_fields'] ) $number_of_fields = (int)($_GET['number_of_fields']); // Firstly Lets build the Category List $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" ); while( $row = mysql_fetch_array( $result ) ) { $photo_category_list .=<<<__HTML_END <option value="$row[0]">$row[1]</option>\n __HTML_END; } mysql_free_result( $result ); // Lets build the Photo Uploading fields while( $counter <= $number_of_fields ) { $photo_upload_fields .=<<<__HTML_END <tr> <td> Photo: <td> <input name='photo_filename[]' type='file' /> </td> </tr> <tr> <td> Caption: </td> <td> <textarea name='photo_caption[]' cols='50' rows='1'></textarea> </td> </tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <form enctype="multipart/form-data" action="upload.php" method="post" name="upload_form" onsubmit="return validate_form();"> <table width='600' border='0' id='tablepadding' align='center'> <tr> <td width='100'> Select Category </td> <td width='500'> <select name='category'> $photo_category_list </select> </td> </tr> <!-Insert the photo fields here --> $photo_upload_fields <tr> <td> <input type='submit' name='submit' value='Add Photo' /> </td> </tr> </table> </form> __HTML_END; ?>
It's this area where I can't figure out how to revise it:
<tr> <td> Photo: <td> <input name='photo_filename[]' type='file' /> </td> </tr>
The [] after photo_filename are causing the issue.
???
-
Hi:
Thanks - it works great! I see you also have it check for a ".co" extension.
I'm not good with RegEx code - never learned much of it.
I guess it's time, huh?
I'll look at it in better detail, but thanks for the help.
-
I don't follow ... That's where I'm stumped on this ... can you give me some direction ...
Thanks.
-
Hi:
I have been trying to get this little email validation to work:
if(empty($Email) || preg_match('~^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$~',$Email)) { $error .= '- Enter your Email.'; } .... <input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" /> ....
If the field is empty, it displays the error message, as it should.
However, it does not work when looking for a proper email, like: mysite@mysite.com
Can anybody tell me what is wrong?
I'm stumped on this ...
Thanks.
-
Hello:
I think this is where I should ask this question.
I have a request to develop a website that will involve a membership component.
They would basically like people to be able to join the site for a free 2-day trial and/or join as a full member.
Can anyone recommend a good 3rd party membership system? Either freeware or a commercial version?
I know this will be hosted on GODaddy and maybe they have something like this already integrated in their hosting packages?
Not sure but this board is always helpful, so any insight would be great.
Thanks!
-
I'm getting confused with what I originally posted, and the new code ..
But, I think I need to find a better upload tutorial/script, anyway.
The one from WC3 works sometimes, but it gives errors that should not be errors (file already exists when it is clear not on the server already, invalid file type when it is clearly a .gif, etc.) ..
Is there a "better" one you can recommend ?
-
Yes, I'm rather confused by this one .. lol ..
-
Hi:
Thanks for the reply, but not quite following.
I have 3 INPUT fields already:
<input type="file" name="file1" /> <input type="file" name="file2" /> <input type="file" name="file3" />
I tried to modify your code like this:
... mysql_real_escape_string($file1), //OTHER DATA mysql_real_escape_string($myProductDecision), mysql_real_escape_string($file2), mysql_real_escape_string($file3)); copy($_FILES['file1']['tmp_name'],"/uploads/".$_FILES['file1']['uploads']); // fmFile being the name of your form field, and the second function parameter being the directory you want to store the file. if(mysql_query($sql)) { ...
But I get the error:
Warning: copy(/uploads/) [function.copy]: failed to open stream: Is a directory in /html/Submit.Product2.php on line 169
I have "Write" permissions added to the folder, so I don't think it's that ..
Maybe my Database field type is wrong ??:
`file1` varchar(255) default NULL, `file2` varchar(255) default NULL, `file3` varchar(255) default NULL,
???
I thought - having done this with ASP - that I should be storing the file names in the Database as a string/text,
and store the files in another folder "uploads"
What am I missing ??
-
Hi again:
What I want to do - and am stuck on - is to allow the user to add files to the feedback, submit the form, and the data will get stored in the DB (and the uploaded files will get stored in "uploads"), plus an email will get sent to the client who can click the files links in the email, and download them that way.
I have done this via ASP, but never tried it with PHP ...
This is what my database table looks like"
CREATE TABLE `myProductRightData2` ( `myDate` varchar(55) default NULL, `myNameAndProduct` text, `myWebsite` text, `myProductUse` text, `myProductProblemSolver` text, `myProductUnique` text, `myWhyBetter` text, `myProductAppeal` text, `myProductSelling` text, `myProductResearch` text, `file1` varchar(255) default NULL, `myProductStory` text, `mySpokesperson` text, `myProductReviewed` text, `myProductDecision` text, `file2` varchar(255) default NULL, `file3` varchar(255) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `myProductRightData2` -- INSERT INTO `myProductRightData2` VALUES('February 22, 2011', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test.pdf', 'test', 'test', 'test', 'test1.jpg', 'test2.jpg');
And this is the form code:
<?php $error = NULL; $myDate = NULL; $myNameAndProduct = NULL; $myPhone = NULL; $myEmail = NULL; $myWebsite = NULL; $myProductUse = NULL; $myProductProblemSolver = NULL; $myProductUnique = NULL; $myWhyBetter = NULL; $myProductAppeal = NULL; $myProductSelling = NULL; $myProductResearch = NULL; $file1 = NULL; $myProductStory = NULL; $mySpokesperson = NULL; $myProductReviewed = NULL; $myProductDecision = NULL; $file2 = NULL; $file3 = NULL; if(isset($_POST['submit'])) { if ((($_FILES["file1"]["type"] == "image/gif") || ($_FILES["file1"]["type"] == "image/jpg") || ($_FILES["file1"]["type"] == "image/jpeg") || ($_FILES["file1"]["type"] == "image/pjpeg")) && ($_FILES["file1"]["size"] < 20000)) { if ($_FILES["file1"]["error"] > 0) { echo "Return Code: " . $_FILES["file1"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file1"]["name"] . "<br />"; echo "Type: " . $_FILES["file1"]["type"] . "<br />"; echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file1"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file1"]["name"])) { echo $_FILES["file1"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file1"]["tmp_name"], "upload/" . $_FILES["file1"]["name"]); echo "Stored in: " . "uploads/" . $_FILES["file1"]["name"]; } } } else { echo "Invalid file"; } $myDate = $_POST['myDate']; $myNameAndProduct = $_POST['myNameAndProduct']; $myPhone = $_POST['myPhone']; $myEmail = $_POST['myEmail']; $myWebsite = $_POST['myWebsite']; $myProductUse = $_POST['myProductUse']; $myProductProblemSolver = $_POST['myProductProblemSolver']; $myProductUnique = $_POST['myProductUnique']; $myWhyBetter = $_POST['myWhyBetter']; $myProductAppeal = $_POST['myProductAppeal']; $myProductSelling = $_POST['myProductSelling']; $myProductResearch = $_POST['myProductResearch']; $file1 = $_POST['file1']; $myProductStory = $_POST['myProductStory']; $mySpokesperson = $_POST['mySpokesperson']; $myProductReviewed = $_POST['myProductReviewed']; $myProductDecision = $_POST['myProductDecision']; $file2 = $_POST['file2']; $file3 = $_POST['file3']; if(empty($myNameAndProduct)) { $error .= '-- Enter your Name and Product. <br />'; } if(empty($myPhone)) { $error .= '-- Enter your Phone Number. <br />'; } if(empty($myEmail)) { $error .= '-- Enter your Email. <br />'; } if($error == NULL) { $sql = sprintf("INSERT INTO myProductRightData2(myDate,myNameAndProduct,myPhone,myEmail,myWebsite,myProductUse,myProductProblemSolver,myProductUnique,myWhyBetter,myProductAppeal,myProductSelling,myProductResearch,file1,myProductStory,mySpokesperson,myProductReviewed,myProductDecision,file2,file3) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($myDate), mysql_real_escape_string($myNameAndProduct), mysql_real_escape_string($myPhone), mysql_real_escape_string($myEmail), mysql_real_escape_string($myWebsite), mysql_real_escape_string($myProductUse), mysql_real_escape_string($myProductProblemSolver), mysql_real_escape_string($myProductUnique), mysql_real_escape_string($myWhyBetter), mysql_real_escape_string($myProductAppeal), mysql_real_escape_string($myProductSelling), mysql_real_escape_string($myProductResearch), mysql_real_escape_string($file1), mysql_real_escape_string($myProductStory), mysql_real_escape_string($mySpokesperson), mysql_real_escape_string($myProductReviewed), mysql_real_escape_string($myProductDecision), mysql_real_escape_string($file2), mysql_real_escape_string($file3)); if(mysql_query($sql)) { $error .= 'Thank you for submitting your product. We will be in contact with you soon.'; mail( "m@sp.com", "Product Submission", "Date Sent: $myDate\n Name and Product: $myNameAndProduct\n Phone: $myPhone\n Email: $myEmail\n Website: $myWebsite\n Product Use: $myProductUse\n Problem Product Solves: $myProductProblemSolver\n Product Uniqueness: $myProductUnique\n Product Better Because: $myWhyBetter\n Product Appeal: $myProductAppeal\n Product Selling Places: $myProductSelling\n Product Research: $myProductResearch\n Research Documentation: $file1\n Product Story: $myProductStory\n Product Spokesperson: $mySpokesperson\n Product Reviewed: $myProductReviewed\n Product Decision Maker: $myProductDecision\n Samples: $file2\n $file3", "From: $Email" ); } else { $error .= 'There was an error in our database, please try again!'; } } } echo '<span class="textError">' . $error . '</span>'; ?> <form name="myform" action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> What is the name of your company and product? <textarea name="myNameAndProduct" cols="72" rows="1"><?php echo $myNameAndProduct; ?></textarea> What is your phone number? <textarea name="myPhone" cols="72" rows="1"><?php echo $myPhone; ?></textarea> What is your email? <textarea name="myEmail" cols="72" rows="1"><?php echo $myEmail; ?></textarea> website we can visit for more information? <textarea name="myWebsite" cols="72" rows="1"><?php echo $myWebsite; ?></textarea> What is this product used for? <textarea name="myProductUse" cols="72" rows="3"><?php echo $myProductUse; ?></textarea> Does this product solve a problem? If so, how? <textarea name="myProductProblemSolver" cols="72" rows="3"><?php echo $myProductProblemSolver; ?></textarea> Does your product have unique or cutting-edge features, ingredients or benefits? <textarea name="myProductUnique" cols="72" rows="3"><?php echo $myProductUnique; ?></textarea> What makes it better than similar products? <textarea name="myWhyBetter" cols="72" rows="3"><?php echo $myWhyBetter; ?></textarea> Does this product have mass appeal? Who is the target audience? <textarea name="myProductAppeal" cols="72" rows="3"><?php echo $myProductAppeal; ?></textarea> Is this product currently selling elsewhere? If so, where and what is the retail price? <textarea name="myProductSelling" cols="72" rows="3"><?php echo $myProductSelling; ?></textarea> Do you have independent research to prove claims about this product? Please provide copies. <textarea name="myProductResearch" cols="72" rows="3"><?php echo $myProductResearch; ?></textarea> Upload independent research copies (Word or PDF files): <input type="file" name="file1" id="file1" /> How and why did your company start? Does that "story" make this product more interesting? <textarea name="myProductStory" cols="72" rows="3"><?php echo $myProductStory; ?></textarea> Do you have a passionate spokesperson that would be comfortable presenting on TV? <textarea name="mySpokesperson" cols="72" rows="3"><?php echo $mySpokesperson; ?></textarea> Has this product ever been submitted to QVC for review? If yes, please provide the details. <textarea name="myProductReviewed" cols="72" rows="3"><?php echo $myProductReviewed; ?></textarea> Who from your company will make the decision to proceed if QVC is presents the right opportunity? <textarea name="myProductDecision" cols="72" rows="3"><?php echo $myProductDecision; ?></textarea> Upload two samples of your product for review (.JPG or PDF files): <input type="file" name="file2" id="file2" /> <input type="file" name="file3" id="file3" /> <input type="submit" name="submit" value="Submit New Product" class="submitButtonProduct" /><br /> </form>
It's essentially the same feedback for I always use and it works fine, but I have been trying to integrate the upload portion into it
from a tutorial I found on W3C: http://www.w3schools.com/PHP/php_file_upload.asp
Any ideas on how to make this work?
-
Hi there:
Yes, will do that now - new topic.
Hope you can look at it - I lost on this one...
-
Excellent!
Thank you very much, it's working like a charm!
On another note:
Are you any good with how to upload and send images with a feedback form?
I'm trying to add this to another form but am a bit lost - haven't made one of these before with PHP and could use some direction ...
-
Hi:
I am using this code for my contact us feedback form:
<?php $error = NULL; $myDate = NULL; $FullName = NULL; $Address = NULL; $City = NULL; $State = NULL; $Zip = NULL; $Phone = NULL; $Email = NULL; $Website = NULL; $Comments = NULL; if(isset($_POST['submit'])) { $myDate = $_POST['myDate']; $FullName = $_POST['FullName']; $Address = $_POST['Address']; $City = $_POST['City']; $State = $_POST['State']; $Zip = $_POST['Zip']; $Phone = $_POST['Phone']; $Email = $_POST['Email']; $Website = $_POST['Website']; $Comments = $_POST['Comments']; if(empty($FullName)) { $error .= '-- Enter your Full Name. <br />'; } if(empty($Email)) { $error .= '-- Enter your Email. <br />'; } if($error == NULL) { $sql = sprintf("INSERT INTO myContactData(myDate,FullName,Address,City,State,Zip,Phone,Email,Website,Comments) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($myDate), mysql_real_escape_string($FullName), mysql_real_escape_string($Address), mysql_real_escape_string($City), mysql_real_escape_string($State), mysql_real_escape_string($Zip), mysql_real_escape_string($Phone), mysql_real_escape_string($Email), mysql_real_escape_string($Website), mysql_real_escape_string($Comments)); if(mysql_query($sql)) { $error .= 'Thank you for contacting us.'; mail( "d@direct.com", "Contact Request", "Date Sent: $myDate\n Full Name: $FullName\n Address: $Address\n City: $City\n State: $State\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Website: $Website\n Comments: $Comments\n", "From: $Email" ); } else { $error .= 'There was an error in our Database, please Try again!'; } } } echo '<span class="textError">' . $error . '</span>'; ?> <form name="myform" action="" method="post"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> <div id="tableFormDiv"> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">* - Required</span></span> <span class="floatFormLeft"> </span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Full Name:</span> <span class="floatFormLeft"><input type="text" name="FullName" size="45" maxlength="50" value="<?php echo $FullName; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Address:</span> <span class="floatFormLeft"><input type="text" name="Address" size="45" maxlength="50" value="<?php echo $Address; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">City:</span> <span class="floatFormLeft"><input type="text" name="City" size="45" maxlength="50" value="<?php echo $City; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">State:</span> <span class="floatFormLeft"><input type="text" name="State" size="45" maxlength="50" value="<?php echo $State; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Zip:</span> <span class="floatFormLeft"><input type="text" name="Zip" size="45" maxlength="50" value="<?php echo $Zip; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Phone:</span> <span class="floatFormLeft"><input type="text" name="Phone" size="45" maxlength="50" value="<?php echo $Phone; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Email:</span> <span class="floatFormLeft"><input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Website:</span> <span class="floatFormLeft"><input type="text" name="Website" size="45" maxlength="50" value="<?php echo $Website; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Comments:</span> <span class="floatFormLeft"><textarea name="Comments" cols="40" rows="10"><?php echo $Comments; ?></textarea></span></fieldset> </div> <input type="submit" name="submit" value="Submit" class="submitButton" /><br /> </form>
I the only thing I can't figure out is, how do I clear the form fields AFTER the form has been submitted and the message
"Thank you for contacting us." appears ??
I haven't been able to figure it out with JavaScript/PHP, so I posted my original code in hopes that someone will have an idea.
Anyone?
Thanks!
-
Excellent!
Thanks works perfectly.
One question:
How would I add more games?
Like this:
... $x = (time() <= strtotime('4/17/2011 2:00:00 AM')) ? 'myUpcoming' : 'myPassed'; $x2 = (time() <= strtotime('5/17/2011 2:00:00 AM')) ? 'myUpcoming' : 'myPassed'; ... <div class=\"". $x ."\"> <span class=\"myGameDate\">April 16:</span> <span class=\"myGameDateRed\">Home</span> vs Baltimore Nighthawks </div> <div class=\"clearAndPad\"></div> <div class=\"". $x2 ."\"> <span class=\"myGameDate\">May 16:</span> <span class=\"myGameDateRed\">Home</span> vs San Diego </div> <div class=\"clearAndPad\"></div> ...
Is that the best way?
-
Hi:
I have this code that - when added to a page - works fine:
<div class=\"<?php echo (time() <= strtotime('4/17/2011 2:00:00 AM')) ? 'myUpcoming' : 'myPassed'; ?>\"> <span class=\"myGameDate\">April 16:</span> <span class="myGameDateRed">Home</span> vs Baltimore </div>
It's a schedule that will display one CSS style before the date, and another CSS style after the date. Works fine on the homepage.
I am trying to add it to an include navigation file, so I can add it to all the pages like this:
myNav.php
function spSchedule() { $spSchedule = " <div class=\". echo time() ." <= strtotime("4/17/2011 2:00:00 AM") ? \"myUpcoming\" : \"myPassed\"; .\"> <span class=\"myGameDate\">April 16:</span> <span class=\"myGameDateRed\">Home</span> vs Baltimore </div> "; return $spSchedule; }
myPage.php:
<?php include('include/myNav.php'); ?> ... <?php echo spSchedule(); ?>
What it is doing is writing "myUpcoming" to the page, and that's it.
What am I missing on this, please?
-
Hi:
Thanks for the link and the code.
Yes, it is working fine now.
The help is appreciated!
-
Hi:
I tried it like this:
<?php if (strtotime(date <= "4/8/2011")) echo "Event Details"; else echo "Default Text"; ?>
But it is not working.
When I change the date to 3/1/2011, it still displays "Event Details"
Can you show me what you mean?
-
Hi:
I am working with a little bit of code, but not certain if my syntax is correct. Doesn't seem to be doing what I need it to do:
<?php if (date <= "4/8/2011") echo "Event Details"; else echo "Default Text"; ?>
Basically, I want to show "Event Details" if the date is before or on 4/8/2011.
If it is after 4/8/2011, I want to show "Default Text"
It seems to be doing the opposite.
What am I missing?
-
Wait! OK, it is working hoe I posted it! Nice...
I didn't realize it was writing it onto the web hosting account.
Do you know how I can adjust it so it will open as a "Save As..." prompt box, so the client
can save it onto his local computer.
That is what he would like.
Thanks for showing me this.
-
Hi:
Thanks for the response - I'm working on your first post.
I did it like this:
<a href="a_Export.php">Export</a>
a_Export.php
<?php include('../include/myConn.php'); backup_tables('bob.db.73909.hosted.com','bob','Rob','blog'); /* backup the db OR just a table */ function backup_tables($host,$user,$pass,$name,$tables = '*') { etc...
I only added the DB connection, and the host, user, password, info.
Problem is, if I click the "Export" link, the page is blank. No errors; but a blank page.
Do I need to alter any of the other code? Like add TABLE names?
Sorry, I just haven't done this before so I don't know where to go with it.
Thanks!
-
Hi:
I think this would pertain to a PHP coding feature.
I want to give a user the ability to click a link in the admin area called "Export Database" the will export the entire database like: myDataBase.sql
and allow them to save it to their computer.
They want to be able to make backups without logging into a PHP admin area.
I use to do this with Access, but have not done this with mySQL.
Has anyone done this before?
-
Hello:
I had a request to do a feature something like this:
http://www.ringcompany.com/RD/RD_Top.aspx?Menu_ID=3&Sub_Menu_ID=2&Design_Code=269826
After you go to the link, click on EDIT and you will see how this works.
Where the text changes based on what is inputted in the text box and writes and warps it self onto the ring.
What I assume is "live image warping"
It looks like it is done in ASP.NET, but since I have never dome anything like this I was hoping for a bit of feedback on how this might be able to be done.
I do not want to commit to this job if it's too far over my head.
Any feedback, please?
-
Hi:
OK, thanks for clarifying.
Question:
Is there a PHP equvilent to ASP's Server.Transfer ??
<% server.transfer "Page.asp" %>
Where I can move a PHP around on the server to another page, and the display it in the browser?
-
Hi:
Does this header redirection:
header("Location: http://www.WebSite.com/Page.php");
Happen on the server, and then get sent to the browser, or is it something that happens on the users computer?
JavaScript Form validator will not work ..
in Javascript Help
Posted
Most excellent!
Thanks for that tip - so simple yet a get workaround.
Much appreciated!