Jump to content

PHP popup form o_O


MannyG

Recommended Posts

Hey I did some browsing on the internet and couldn't turn much up so I am quite sure you cannot do a popup style form in PHP (probably can in Javascript). I want to do a PHP-MySQL form related thing that inserts data into a mysql table via the button, and when u click the button a form pops up bu fill out and submit and it will go into the database and display in a html table.

 

Any ideas or help?

 

I am very...new to javascript and was wondering if there is something in PHP related to this method?

Link to comment
https://forums.phpfreaks.com/topic/197913-php-popup-form-o_o/
Share on other sites

If you want a popup, you'll have to use javascript, but it's easy enough to do:

 

<a href="pagename.php" target="popup"
onClick="wopen('pagename.php', 'popup', 600, 600); return false;">

 

That will open "pagename.php" in a 600x600 window.

 

You can enter your form info there, and the process section of it as well if you use (isset)

 

If it is changing data on the main page and you'd like to reflect the new data, you can even refresh the main page when you close the popup by including this:

 

<body onunload="window.opener.location=window.opener.location;">

 

inside of the page that is in the popup.

 

Pretty neat, eh?

 

Link to comment
https://forums.phpfreaks.com/topic/197913-php-popup-form-o_o/#findComment-1038557
Share on other sites

It opens in a new tab, not a popup...o_O here is what it looks like

 

 

<?php
//Add a record
echo "<a href = 'addRow.php' target='popup'><input type=\"button\" value=\"Add Record\" onclick=\"javascript:\"wopen('addRow.php', 'popup', 600, 600); return false;\">";
?>

 

and now here is the addRow.php form

 

<body onunload="javascript:window.opener.location=window.opener.location;">
<?php
##Connection to Database
$conn = mysql_connect("javasrv19", "", "") or die("Could not connect : " . mysql_error());
mysql_select_db("javaconformance_testproject", $conn) or die("Could not select database");


echo "<center>";
  echo "<form method='POST' action='Edit3Insert.php'>";
      echo "<h1><b>Edit Results</b></h1></br>";
    echo "<p class='hlight'><b>Testcase Num</b>";
//form data
  echo   "<input type='text' name='tcnum' value='' maxlength='50' size='30'>";
   echo   "</p>";
   //form data
echo	"<p class='hlight'><b>Name</b>";
  echo   " <input type='text' name='name' value='' maxlength='50' size='30'>";
  echo    "</p>";
  //form data
echo	"<p class='hlight'><b>JSR Req</b>";
echo    " <input type='text' name='jsr' value='' maxlength='50' size='30'>";
echo    " </p>";
//form data
echo	"<p class='hlight'><b>Description</b>";
echo    " <input type='text' name='desc' value='' maxlength='50' size='30'>";
echo    " </p>";

echo "<p>";
   echo   "<input type='submit' name='submit' value='Submit'>";
    echo "</form>";
   echo "</p>";
  
echo "</center>";
?>

Link to comment
https://forums.phpfreaks.com/topic/197913-php-popup-form-o_o/#findComment-1038596
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.