Steven D Posted March 8, 2008 Share Posted March 8, 2008 Hello, My Name Is Steven. I need help with my PHP Form. I made it but I want to make it do the following: 1:Send The Submitted Information To A Log File That Is Neatly Organized which included (Data Submitted, IP Address). 2:I have an Email Area, I want to only allow certain Email(s) to Submit. Can Anyone Help Me? Thanks! ~Steven Link to comment https://forums.phpfreaks.com/topic/95118-php-form-help/ Share on other sites More sharing options...
Steven D Posted March 8, 2008 Author Share Posted March 8, 2008 Forgot to mention, For the Email, can their be a Wizard if possible, I dont care if you cant do it. I just want them to enter the valid Email Address, not their whatever. Link to comment https://forums.phpfreaks.com/topic/95118-php-form-help/#findComment-487261 Share on other sites More sharing options...
dk1983 Posted March 8, 2008 Share Posted March 8, 2008 I'll give you a bit of code that looks like PHP but probably has minor errors: <?php // Loop through POSTed data and stick it in a string foreach($_POST as $key=>$value) { // Should probably do some validation checks on those $values here $string .= $key . ": " . $value . "\n"; } // Add the users IP address to the string $string .= "IP: " . $_SERVER['REMOTE_ADDR'] . "\n"; // Stick the string into a file file_put_contents("/your_textfile_path/your_textfile.txt", $string); ?> Once any syntax errors are removed; in theory, that should get you a fairly straightforward text file. Obviously you'll need to change the path to your intended text / log file. Dave Link to comment https://forums.phpfreaks.com/topic/95118-php-form-help/#findComment-487271 Share on other sites More sharing options...
Steven D Posted March 8, 2008 Author Share Posted March 8, 2008 Can u tell me how to add that to... <form name="add" action="submit.php" method="post" target="_self" onsubmit="return chk(event);"> <table cellspacing="0" class="ta sub" id="sbo" align="center"> <tr><th>#</th><th>Download Title</th><th>Download URL</th><th>Type</th></tr> <tr><td>1:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt0" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du0" onchange="donh(this.id);"></td> <td><select name="type[]" id="se0" onchange="donh(this.id);"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>2:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt1" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du1" onchange="donh(this.id);"></td> <td><select name="type[]" id="se1"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>3:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt2" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du2" onchange="donh(this.id);"></td> <td><select name="type[]" id="se2"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>4:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt3" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du3" onchange="donh(this.id);"></td> <td><select name="type[]" id="se3"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>5:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt4" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du4" onchange="donh(this.id);"></td> <td><select name="type[]" id="se4"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>6:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt5" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du5" onchange="donh(this.id);"></td> <td><select name="type[]" id="se5"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>7:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt6" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du6" onchange="donh(this.id);"></td> <td><select name="type[]" id="se6"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>8:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt7" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du7" onchange="donh(this.id);"></td> <td><select name="type[]" id="se7"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>9:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt8" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du8" onchange="donh(this.id);"></td> <td><select name="type[]" id="se8"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr> <tr><td>10:</td><td><input type="text" name="title[]" size="50" maxlength="72" id="dt9" onchange="donh(this.id);"></td> <td><input type="text" name="url[]" size="30" id="du9" onchange="donh(this.id);"></td> <td><select name="type[]" id="se9"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="000">000</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></tr></table> <br /><table cellspacing="10" cellpadding="0" class="sub" align="center"> <tr><td rowspan="3" width="10"></td><td>Site Name:* </td><td><input type="text" name="sname" size="20" maxlength="20" id="dsn" onchange="donh(this.id);"></td> <td> Site URL:* </td><td><input type="text" name="surl" size="30" id="dsu" onchange="donh(this.id);"></td></tr> <tr><td>E-mail:*</td><td colspan="4"><input type="text" name="email" size="20" id="dem" onchange="donh(this.id);"> <em>* = required</em></td></tr> <tr><td colspan="4" style="text-align:center;"><br /> <input type="submit" value="Submit Download(s)" style="width:216px;cursor:pointer;"> <br><strong>Press only once!</strong></td></tr></table></form> Thanks! Link to comment https://forums.phpfreaks.com/topic/95118-php-form-help/#findComment-487277 Share on other sites More sharing options...
Steven D Posted March 8, 2008 Author Share Posted March 8, 2008 Above Is My PHP Form ^^^ Can Someone help Me? By Modifying The Code? Link to comment https://forums.phpfreaks.com/topic/95118-php-form-help/#findComment-487280 Share on other sites More sharing options...
dk1983 Posted March 8, 2008 Share Posted March 8, 2008 Wow, thats a lot of code. Remember this: Semantics and Standards Compliance are your friends. A quick roll-your-own-solution: Insert that code I posted above into the top of your file. Place it between an IF statement that checks whether the page has recieved any POST data... <?php if($_POST) { // That code above } // Carry on as normal... ?> <html> <head></head> <body> <form>... Then, below all that you've got your HTML <head>, <body> followed by your form. Have your form's "action" set as the name of this your the same page - when the user submits the form, it will send the data back to itself. Dave Link to comment https://forums.phpfreaks.com/topic/95118-php-form-help/#findComment-487288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.