tuxandpucks
Members-
Posts
17 -
Joined
-
Last visited
tuxandpucks's Achievements
Newbie (1/14)
0
Reputation
-
Hey everyone, I am in need of that high quality help I receive when visiting this website. In short, I have a php script that is supposed to automatically submit data to a MySQL database but the data doesn't seem to make it to the database. I am not good at debugging and I am not getting any errors on the pages when I submit an entry. Basically I have this code which takes in the information and as you know/can tell it calls on another php script to do the auto submit to the database. Here is this code: </head> <?php include('../templates/bodyandlogo.htm'); ?> <?php include('../templates/navmenu.htm'); ?> <br /> <br /> <h1>PoemScribe: Order Form</h1> <br /> <br /> <p>Please complete the form below and click submit to order your personalized poem.</p> <br /> <br /> <div id="form"> <form action="../php_scripts/orderform.php" method="post"> <label for="firstname">First Name:</label> <div class="input"><input type="text" id="firstname" name="firstname" /></div><br /> <label for="lastname">Last Name:</label> <div class="input"><input type="text" id="lastname" name="lastname" /></div><br /> <label for="email">Email:</label> <div class="input"><input type="text" id="email" name="email" /></div><br /> <label for="selectpoemtype">Select Poem Type:<br /> 4-Line Poem: $15 8-Line Poem: $25 12-Line Poem: $40 16-Line Poem: $50 20-Line Poem: $75 Please type in your desired poem length. Example: "4line". </label><br /> <div class="input"><input type="text" id="selectpoemtype" name="selectpoemtype" /><br /> <br /> <br /> <label for="keynames">"Key names to include?"</label> <div class="input"><input type="text" id="keynames" name="keynames"/></div><br /> <label for="specificwords">Any specific words you would like to include in your poem?</label> <div class="input"><input type="text" id="specificwords" name="specificwords" /></div><br /> <label for="poemisfor">Who is the poem for?</label> <div class="input"><input type="text" id="poemisfor" name="poemisfor" /></div><br /> <label for="relationship">Relationship to you?</label> <div class="input"><input type="text" id="relationship" name="relationship" /></div><br /> <label for="occasion">What is the occasion for this poem?</label> <div class="input"><input type="text" id="occasion" name="occasion" /></div><br /> <label for="overallmessage">What do you want the overall message of this poem to be?</label> <div class="input"><input type="text" id="overallmessage" name="overallmessage" /></div><br /> <label for="anythingelse">Any other information you would like for me to know?</label> <div class="input"><input type="text" id="anythingelse" name="anythingelse" /></div><br /> <div class="input"><input type="submit" value="Submit" name="submit"</div> </form> </div><!--form--> <br /> <br /> <?php include('../templates/footer.htm'); And then the code that is called on (the script called orderform.php): <!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" xml:lang="en" lang="en"> <head><title>PoemScribe Order Form</title> </head> <body> <h2>PoemScribe</h2> <?php $email = "myemail@gmail.com"; // Email to notify on error $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $email = $_POST['email']; $select_poem_type = $_POST['selectpoemtype']; $key_names = $_POST['keynames']; $specific_words = $_POST['specificwords']; $poem_is_for = $_POST['poemisfor']; $relationship = $_POST['relationship']; $occasion = $_POST['occasion']; $over_all_message = $_POST['overallmessage']; $anything_else = $_POST['anythingelse']; $dbc = mysqli_connect('localhost', 'login', 'password', 'database'); " . or die('Error connecting to MySQL server.'); $query = INSERT INTO poem_orders '(firstname, lastname, email, selectpoemtype, keynames, specificwords, poemisfor, " . "relationship, occasion, overallmessage, anythingelse)" . "VALUES ('$first_name', '$last_name', '$email', '$select_poem_type' '$key_names', '$specific_words', '$poem_is_for', " . "'$relationship', '$occasion', '$over_all_message', '$anything_else')"; echo 'Thank you, ' . $firstname . $lastname; echo 'Thanks for submitting the form.<br />'; echo ' Poem Type: ' . $selectpoemtype; echo ' Key names to include: ' . $keynames . '<br />'; echo 'Specific Words To Include: '. $specificwords . '<br />'; echo 'Poem is for: ' . $poemisfor . '<br />'; echo 'Relationship: ' . $relationship . '<br />'; echo 'Occasion: ' . $occasion . '<br />'; echo 'Overall Message: ' . $overallmessage . '<br />'; echo 'You also added: ' . $anything_else; mysqli_close($dbc); ?> </body> </html> Again, I am trying to figure out why my database isn't being populated when someone clicks on the submit button. I tried the code Larry shows on pages 352-354 of this book, but I couldn't get it to work, so I am now trying the code posted above. Any help is appreciated. Thanks in advance, Randy
-
Thanks for the input. If you are curious, the web page I am working on for this, is: http://www.poemscribe.com/pages/samplepoems.htm I guess my next step for design is to decide how I am going to make it so that when a visitor presses one of the buttons, a list of poems comes up. I haven't decided how I want to go about this. Randy
-
I really, truly appreciate the direct coaching you folks are giving me. Here is what phpmyadmin printed, when I selected "Print". poems Field Type Null Default Comments id int(11) No title varchar(255) No category_id int(3) No Indexes: Keyname Type Unique Packed Field Cardinality Collation Null Comment PRIMARY BTREE Yes No id 0 A and this snippet was also showing after I created the db: CREATE TABLE `tuxandp1_poems`.`poems` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR( 255 ) NOT NULL , `category_id` INT( 3 ) NOT NULL ) ENGINE = MYISAM ; I guess my next step is to ask, How do I enter each of the letters of the alphabet so I may start entering poem titles? Or, is there something else to do first? Thank you, Randy
-
I actually would love to use Mysql and my hosting provider has phpmyadmin already for me to use......i simply have never used Mysql and although i looked into it even using larry's php book i jist struggled woth it. If u could provide an example of how to enter my data i would certainly be willing to try agaon. O want to have my database table callwd poems, then letters a to z and just list my poems under each letter. Thank you for the help. Randy
-
Hey everyone, I am attempting to create an array with my various poem titles that visitors to my website will be able to click on the poem title and read it. My question is, how do I add the actual poem to this array (this is a short example of my code)? So far I created the overall array for all the letters to sort with, A, B, C, etc., and the titles of each poem. Do I somehow add a link to the title to make that happen and have the link simply point to another html page? I'm starting to think that an actual poem with many lines doesn't fit into an array. Not sure what to do. Code: $poemsa = array ('All Over Town', 'Angel Upon A Breath',); $poemsb = array ('The Battle of the Bulge'); $poemsc = array ('Choose', 'Coffee Anyone?', 'Coffee History', 'Combustion', 'Crash Test', ); $poemsd = array ('Double Meaning'); //Multidimensional Array $poems = array( 'A' => $poemsa, 'B' => $poemsb, 'C' => $poemsc, 'D' => $poemsd, So far I can successfully run these two bits of code: Code: print "<p>Poem:<i>{$poems['A'][0]}</i>.</p>"; foreach ($poems as $letter => $poem) { echo "<p>$letter: $poem</p>\n"; } Any ideas? Thank you, Randy