Jump to content

not sure how to word what I need


niquel65

Recommended Posts

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

Link to comment
Share on other sites

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' ) ;
}
?>

Link to comment
Share on other sites

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  8)

Link to comment
Share on other sites

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...";

 

 

Link to comment
Share on other sites

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.  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.