ciao ragazzi premetto che nn ho molte basi di php quindi cercate di essere il più chiaro possibili voglio creare un form che mi deve far registrare un utente e poi gli fa visualizzare i dati inseriti e me li salva nel mio database (a proposito per salvare i dati nel mio database mi creo a parte delle tabelle in mysql??? e se la risposta è si come lo collego con il codice???)il problema sta nel fatto che la pagina del form si vede ma dopo nella pagina successiva i dati nn vengono visualizzati. Chi mi spiega come posso fare?
questo è il primo file che ho chiamato form.html
questo è il secondo file che ho chiamato form.phpcodice:<!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> <title>Sample form to take user input in XHTML</title> </head> <body> <h1>This is a sample registration form.</h1> Please fill in all fields and click Register. <form method = "post" action = "form.php"> <img src = "images/user.gif" alt = "User" /> <span style = "color: blue"> Please fill out the fields below. </span> <img src = "images/fname.gif" alt = "First Name" /> <input type = "text" name = "fname" /> <img src = "images/lname.gif" alt = "Last Name" /> <input type = "text" name = "lname" /> <img src = "images/email.gif" alt = "Email" /> <input type = "text" name = "email" /> <img src = "images/phone.gif" alt = "Phone" /> <input type = "text" name = "phone" /> <span style = "font-size: 10pt"> Must be in the form (555)555-5555</span> <img src = "images/downloads.gif" alt = "Publications" /> <span style = "color: blue"> Which book would you like information about? </span> <select name = "book"> <option>Internet and WWW How to Program 3e</option> <option>C++ How to Program 4e</option> <option>Java How to Program 5e</option> <option>XML How to Program 1e</option> </select> <img src = "images/os.gif" alt = "Operating System" /> <span style = "color: blue"> Which operating system are you currently using? </span> <input type = "radio" name = "os" value = "Windows XP" checked = "checked" /> Windows XP <input type = "radio" name = "os" value = "Windows 2000" /> Windows 2000 <input type = "radio" name = "os" value = "Windows 98" /> Windows 98 <input type = "radio" name = "os" value = "Linux" /> Linux <input type = "radio" name = "os" value = "Other" /> Other <input type = "submit" value = "Register" /> </form> </body> </html>
Ringrazio anticipatamente tutti quelli che mi spiegano cosa fare o come fare....codice:<!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> <title>Form Validation</title> </head> <body style = "font-family: arial,sans-serif"> <?php extract( $_POST ); // determine whether phone number is valid and print 18 // an error message if not if ( !ereg( "^\([0-9]{3}\)[0-9]{3}-[0-9]{4}$", $phone ) ){print( " <span style = \"color: red; font-size: 2em\"> INVALID PHONE NUMBER</span> A valid phone number must be in the form (555)555-5555 <span style = \"color: blue\"> Click the Back button, enter a valid phone number and resubmit. Thank You.</span></p></body></html>" ); die(); // terminate script execution } ?> Hi <span style = "color: blue"> <?php print( "$fname" ); ?> </span>. Thank you for completing the survey. You have been added to the <span style = "color: blue"> <?php print( "$book " ); ?> </span> mailing list. </p> The following information has been saved in our database: <table border = "0" cellpadding = "0" cellspacing = "10"> <tr> <td bgcolor = "#ffffaa">Name </td> <td bgcolor = "#ffffbb">Email</td> <td bgcolor = "#ffffcc">Phone</td> <td bgcolor = "#ffffdd">OS</td> </tr> <tr> <?php // print each form field’s value print( "<td>$fname $lname</td> <td>$email</td> <td>$phone</td> <td>$os</td>" ); ?> </tr> </table> <div style = "font-size: 10pt; text-align: center"> This is only a sample form. You have not been added to a mailing list. </div> </body> </html>
P.S. Potrei anche togliere la pagina che visualizza i dati (Form.php) ma mi rimane sempre il problema di salvare i dati. Grazie 1000

Rispondi quotando

