niquel65 Posted July 29, 2010 Share Posted July 29, 2010 I'm going to post the code that I am currently using and then explain what I'm trying to do. I hope I can explain it well enough. <?php if (!isset($_POST['submit'])) { echo'<leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0"> <center><form name="fairlistlist" method="POST" action="'.$_SERVER['PHP_SELF'].'"> <TABLE width="450" height="119" border=0 cellPadding=3 cellSpacing=2 bgcolor="#fff568"> <TBODY> <TR> <TD class=mainText width="100"><b>Event Name</b></TD> <TD width="305" class=frmInput> <INPUT class=mainFormBox style="WIDTH: 320px" type="text" name=" fairname"></TD> </TR> <TR> <TD class=mainText width="100"><B>Event Address</B></TD> <TD class=frmInput> <INPUT name="fairadd" type="text" class=mainFormBox id="fairadd" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event City</b></TD> <TD class=frmInput> <INPUT name="faircity" type="text" class=mainFormBox id="faircity" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event County</b></TD> <TD class=frmInput> <INPUT name="faircty" type="text" class=mainFormBox id="faircty" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event State</b></TD> <TD class=frmInput> <INPUT name="fairstate" type="text" class=mainFormBox id="fairstate" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Country</b></TD> <TD class=frmInput> <INPUT name="fairctry" type="text" class=mainFormBox id="fairctry" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Opening Date</b></TD> <TD class=frmInput> <INPUT name="fairopen" type="text" class=mainFormBox id="fairopen" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Closing Date</b></TD> <TD class=frmInput> <INPUT name="fairclose" type="text" class=mainFormBox id="fairlose" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Contact Email</b></TD> <TD class=frmInput> <INPUT name="fairmail" type="text" class=mainFormBox id="fairmail" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Website</b></TD> <TD class=frmInput> <INPUT name="fairweb" type="text" class=mainFormBox id="fairweb" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=frmDescription width="56"> </TD> <TD class=frmInput> <div align="right"> <input type="submit" name="submit" value="Add my Event" /> </div></TD> </TR> </TBODY> </TABLE> </form></center> </body>'; //note that I added a new field called submit and it's hidden .. } else { /*I added addslashes() so it escape any special char in the form .. if you want to show your inserted record , you need to use stripslashes() to remove any slashes from the record .. this is only to avoid some security problems in the query ..*/ $fairname=trim(addslashes($_POST['fairname'])); $fairadd=trim(addslashes($_POST['fairadd'])); $faircity=trim(addslashes($_POST['faircity'])); $faircty=trim(addslashes($_POST['faircty'])); $fairstate=trim(addslashes($_POST['fairstate'])); $fairctry=trim(addslashes($_POST['fairctry'])); $fairopen=trim(addslashes($_POST['fairopen'])); $fairclose=trim(addslashes($_POST['fairclose'])); $fairmail=trim(addslashes($_POST['fairmail'])); $fairweb=trim(addslashes($_POST['fairweb'])); include("Connections/local.php"); $link = mysql_connect($hostname_local,$username_local, $password_local) or die("Could not connect"); mysql_select_db('fair123') or die("Could not select database"); $insert=mysql_query("INSERT INTO events (fairidnum, fairname, fairadd, faircity, faircty, fairstate, fairctry, fairopen, fairclose, fairmail, fairweb) VALUES('NULL', '$fairname', '$fairadd', '$faircity', '$faircty','$fairstate', '$fairctry','$fairopen', '$fairclose', '$fairmail', '$fairweb')")or die('couldn\'t Insert record into database :'.mysql_error()); header( 'Location: event_added.php' ) ; } ?> Especially look at the code part here $insert=mysql_query("INSERT INTO events (fairidnum, fairname, fairadd, faircity, faircty, fairstate, fairctry, fairopen, fairclose, fairmail, fairweb) VALUES('NULL', '$fairname', '$fairadd', '$faircity', '$faircty','$fairstate', '$fairctry','$fairopen', '$fairclose', '$fairmail', '$fairweb')")or die('couldn\'t Insert record into database :'.mysql_error()); header( 'Location: event_added.php' ) ; } ?> this is where I am having problems it was reading echo your record has been successfully added to the database What I want is for it to open up a new page with my menu and my css and all that good crap to a page where it will read the following Your information has been added to our database We have added Event name = "whatever the event's name was" Event address = "address:" so on and so on for all the fields in my form that was submitted to the database. with just using the echo command it always opened to just a blank page no formatting and no css as well as no all important links Can you please tell me what I'm doing wrong or where I can find a good guideline that Is easy to understand on how to do this? Thanks in advance Oh also I don't care if that page get's indexed by google or yahoo or not actually prefer it don't get indexed to be honest Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/ Share on other sites More sharing options...
inversesoft123 Posted July 29, 2010 Share Posted July 29, 2010 page1.php <?php ?> <leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0"> <center><form name="fairlistlist" method="POST" action="page2.php"> <TABLE width="450" height="119" border=0 cellPadding=3 cellSpacing=2 bgcolor="#fff568"> <TBODY> <TR> <TD class=mainText width="100"><b>Event Name</b></TD> <TD width="305" class=frmInput> <INPUT class=mainFormBox style="WIDTH: 320px" type="text" name=" fairname"></TD> </TR> <TR> <TD class=mainText width="100"><B>Event Address</B></TD> <TD class=frmInput> <INPUT name="fairadd" type="text" class=mainFormBox id="fairadd" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event City</b></TD> <TD class=frmInput> <INPUT name="faircity" type="text" class=mainFormBox id="faircity" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event County</b></TD> <TD class=frmInput> <INPUT name="faircty" type="text" class=mainFormBox id="faircty" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event State</b></TD> <TD class=frmInput> <INPUT name="fairstate" type="text" class=mainFormBox id="fairstate" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Country</b></TD> <TD class=frmInput> <INPUT name="fairctry" type="text" class=mainFormBox id="fairctry" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Opening Date</b></TD> <TD class=frmInput> <INPUT name="fairopen" type="text" class=mainFormBox id="fairopen" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Closing Date</b></TD> <TD class=frmInput> <INPUT name="fairclose" type="text" class=mainFormBox id="fairlose" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Contact Email</b></TD> <TD class=frmInput> <INPUT name="fairmail" type="text" class=mainFormBox id="fairmail" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=mainText width="100"><b>Event Website</b></TD> <TD class=frmInput> <INPUT name="fairweb" type="text" class=mainFormBox id="fairweb" style="WIDTH: 320px"></TD> </TR> <TR> <TD class=frmDescription width="56"> </TD> <TD class=frmInput> <div align="right"> <input type="submit" name="submit" value="Add my Event" /> </div></TD> </TR> </TBODY> </TABLE> </form></center> </body>'; //note that I added a new field called submit and it's hidden .. page2.php <?php if (!isset($_POST['submit'])) { /*I added addslashes() so it escape any special char in the form .. if you want to show your inserted record , you need to use stripslashes() to remove any slashes from the record .. this is only to avoid some security problems in the query ..*/ $fairname=trim(addslashes($_POST['fairname'])); $fairadd=trim(addslashes($_POST['fairadd'])); $faircity=trim(addslashes($_POST['faircity'])); $faircty=trim(addslashes($_POST['faircty'])); $fairstate=trim(addslashes($_POST['fairstate'])); $fairctry=trim(addslashes($_POST['fairctry'])); $fairopen=trim(addslashes($_POST['fairopen'])); $fairclose=trim(addslashes($_POST['fairclose'])); $fairmail=trim(addslashes($_POST['fairmail'])); $fairweb=trim(addslashes($_POST['fairweb'])); include("Connections/local.php"); $link = mysql_connect($hostname_local,$username_local, $password_local) or die("Could not connect"); mysql_select_db('fair123') or die("Could not select database"); $insert=mysql_query("INSERT INTO events (fairidnum, fairname, fairadd, faircity, faircty, fairstate, fairctry, fairopen, fairclose, fairmail, fairweb) VALUES('NULL', '$fairname', '$fairadd', '$faircity', '$faircty','$fairstate', '$fairctry','$fairopen', '$fairclose', '$fairmail', '$fairweb')")or die('couldn\'t Insert record into database :'.mysql_error()); echo "Events Added!"; } else { header( 'Location: page1.php' ) ; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092443 Share on other sites More sharing options...
niquel65 Posted July 29, 2010 Author Share Posted July 29, 2010 If i am right all that will do is again show on a blank page event added (with no formating/links) and if not added will take them back to the page to resubmit the information. If i read all the code correctly. However my problem it isn't showing the (for lack of a better name for the html and css portions of my site) template only a blank page with just event added which isn't adequate for what I have in mind. I do appreciate your looking at it though Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092447 Share on other sites More sharing options...
inversesoft123 Posted July 29, 2010 Share Posted July 29, 2010 If you check echo "Events Added!"; in my updated code. U can simply echo all the form elements. like $fairname = $_POST['fairname']; $fairadd = $_POST['fairadd']; // And so on after this echo "We have added following records into the database:<br/>Event name = \"$fairname\"<br/>Event address = \"$fairadd\"<br/>And so on..."; Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092451 Share on other sites More sharing options...
niquel65 Posted July 29, 2010 Author Share Posted July 29, 2010 OK, i tried this and it displayed record was added but when I go to look for it in myphpadmin it is not adding the fields at all to the database Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092626 Share on other sites More sharing options...
AtlasC1 Posted July 29, 2010 Share Posted July 29, 2010 Has your question been answered yet? Unfortunately, I don't quite understand the problem in regards to the css of your site. Your styles reside in an external .css file, and you're linking to it from all of your pages? Are we assuming you have a proper <link rel="stylesheet" type="text/css" href="style.css" /> somehow implemented in all of your pages? Because, I don't see that anywhere in the code. If not, there's your problem. Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092638 Share on other sites More sharing options...
niquel65 Posted July 29, 2010 Author Share Posted July 29, 2010 that may be my problem all together where would I add that too in the php code. I am assuming it would go at the very top. Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092639 Share on other sites More sharing options...
AtlasC1 Posted July 29, 2010 Share Posted July 29, 2010 In short... yes, between <head></head> tags :-\. You could also write a function to do that for you on each of your pages. Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092645 Share on other sites More sharing options...
niquel65 Posted July 29, 2010 Author Share Posted July 29, 2010 OK thanks I will try that and see what I get I'm still not really understanding css and usually just save my design page and put everything in the HTML code however it seems php don't allow me to do that when they dynamic page will clear the page and say just record added So I am having to experiment with the css now Quote Link to comment https://forums.phpfreaks.com/topic/209183-not-sure-how-to-word-what-i-need/#findComment-1092647 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.